arrays

For the Compleat Fan
Locked
didi
Posts: 166
Joined: Fri May 04, 2007 8:24 pm
Location: Germany

arrays

Post 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 .

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post by Jeff »

You could just do:

Code: Select all

(set 'pic (array 100 100 '(3)))
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

didi
Posts: 166
Joined: Fri May 04, 2007 8:24 pm
Location: Germany

Post by didi »

It works . Thankyou Jeff .
And how can i get rid of the display of the hole array in the console-window ?

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post 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.
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

Locked