[Back to GSN Home Page] [Back to Message Index]

Global SchoolNet - Automated Message Archive

LOGO-L> Re: MSWLOGO mdarray with variables




jstclair@omsd.cerf.fred.org
Thu, 25 Jan 96 11:50 pdt

--Message below re-posted by <jstclair@omsd.cerf.fred.org>
Date - 24 Jan 1996 15:56:32 GMT
To - jstclair@omsd
Subject - Re: MSWLOGO mdarray with variables
Usenet: comp.lang.logo
------------------
Post Usenet mail to comp-lang-logo@ucbvax.berkeley.edu
------------------

jim@wvlink.mpl.com (Jim Poling) writes:
>I get an error with the following piece of code. Can I not use a
>variable in a multi-dimensional array definition?
>
>to test
>make "pointc 433
>print :pointc
>make "dumarray (mdarray [:pointc 3] 0)
>show :dumarray
>end

The problem has nothing to do with mdarray; you are misunderstanding
how to construct a list in Logo.

When you put things in square brackets, you are creating a LITERAL
(a/k/a QUOTED) list; the values in the list are exactly the words
you type. So in your list [:pointc 3] the first element is not
"the value of the variable named pointc" but rather "the seven-letter
word colon, p, o, i..."

The way to create a list whose contents vary is to use the LIST
operation: instead of [:pointc 3] you say

list :pointc 3

So you could say

make "dumarray (mdarray (list :pointc 3) 0)

and your program will work as desired.


---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org. Mail
questions about the list administration to logofdn@gsn.org. To
unsubscribe send unsubscribe logo-l to majordomo@gsn.org.