arrays

Started by didi, May 07, 2007, 10:13:08 AM

Previous topic - Next topic

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 .

Jeff

#1
You could just do:


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

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

didi

#2
It works . Thankyou Jeff .  

And how can i get rid of the display of the hole array in the console-window ?

Jeff

#3
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.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

Lutz

#4
to get rid of displaying the return value from the array statement, just wrap any other functin around it:


(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':


(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">http://newlisp.org/downloads/newlisp_manual.html#array