Page 1 of 1

arrays

Posted: Mon May 07, 2007 5:13 pm
by didi
To initialize a big array with a certain value this is the only method i found :

( set 'pic ( array 100 100 ( sequence 3 3 ) ) )


1. Is there any other method to initialize it to a certain number or a string ?

2. How can i stop the output in the console-window while the array
is evaluated ?

PS: As you can imagine i want this for a byte-map for simple graphics . The size could be eg. 1000 x 1000 later .

Posted: Mon May 07, 2007 5:53 pm
by Jeff
You could just do:

Code: Select all

(set 'pic (array 100 100 '(3)))

Posted: Mon May 07, 2007 6:00 pm
by didi
It works . Thankyou Jeff .
And how can i get rid of the display of the hole array in the console-window ?

Posted: Mon May 07, 2007 6:06 pm
by Jeff
In the repl (the interactive interpreter), whatever the last expression evaluates to gets printed to the screen (repl = read-eval-print-loop). I don't think it outputs anything when run from the cli.

Posted: Mon May 07, 2007 6:38 pm
by Lutz
to get rid of displaying the return value from the array statement, just wrap any other functin around it:

Code: Select all

(time (set 'pic (array 100 100 '(3))))
of course this is only a problem when executing the statement interactively. Inside a program you wouldn't see anything which isn't printed explictely.

or you can use 'silent':

Code: Select all

(silent (set 'pic (array 100 100 '(3))))
it suppresses everything, including the prompt, so hit <enter> to get the prompt back.

Lutz

see also: http://newlisp.org/downloads/newlisp_manual.html#array