first , my mistake for not mentioning which LOGO I am using. I am using PC
LOGO 2.0 for MSW.
I believe that I do have the matching brackets.
I tried to part of the FOR loop on the next line and I got an error message
needing more inputs. The FOR loop supports no increment if the increment is
1.
Although the help and reference manual show brackets around the dimensions
of the array, when I remove the brackets then I get an error message, that
ASET requires more inputs.
Is this a similar problem that I dealt with (SORRY, BUT I JUST DISCOVERED
THE SOLUTION!)
I had some difficulty with the PRINT part. When I put PRINT [:I :J],
the result was :I :J when I was expecting number results. I then tried
PRINT :I and I got a result, 0 before the error message. Then I put PRINT
:J and on the next line I got another 0 before the error message. So my
next concern was to put both I and J on the same line. When I put PRINT (SE
:I :J), then I got '0 0' before the error message. As you might have
figured out, I just realized I needed to do the same for the list for ASET.
|
\|/
The program works with ASET :CHESS_POS (SE :I :J) (SE (44 ...)).
The necessary change was to put the array position as a sentence, not in
brackets, as my reference guide shows. Is this true of variables but works
with numeric values? I don't know.
>From: George Mills <mi...@softronix.com>
>To: john wood <jlwo...@hotmail.com>
>CC: log...@gsn.org
>Subject: Re: LOGO-L> numbers? for ASET for an array
>Date: Tue, 06 Jul 1999 18:35:26 -0400
>
>Well I'm not sure which Logo you are using since very few Logo's support
>FOR loops and ARRAY's.
>
>But in UCB/MSWLogo the code would look something like this, which has
>slightly different syntax.
>
>But in general, you are missing two right brackets (a good reason to indent
>your code with each
>pair of brackets visibly matched).
>
>I would hope any Logo allows you to indent the code as you suggested but
>UCB/MSWLogo requires some
>continuation symbols (~). Also multidimensional arrays are created with
>MDARRAY in UCB/MSWLogo.
>
>Also, I believe you have some issues with constructing your lists of
>information that you want
>"resolved". [:I :J] builds a list with the WORDS :I and :J not the value of
>I and J. Use the
>function LIST to resolve these into their values. Same problem applies to
>the data you are
>trying to place into the the array (which I assume was a list also).
>
>Note also that UCB/MSWLogo allow you to set the base index to be what you
>want (usually 0 or 1).
>I have told it to allow a base index of 0 since a base index 1 is the
>default and not appropriate here.
>
>Note also that UCB/MSWLogo requires a delta for the FOR loop counter.
>
>That should give you enough information to translate my changes back into
>your logo.
>
>TO CREATE_ARRAY
> make "SQ.SZ 100
> MAKE "CHESS_POS (MDARRAY [8 8] 0)
> FOR [I 0 7 1]~
> [
> FOR [J 0 7 1]~
> [
> mdsetitem (list :I :J) :CHESS_POS (list 44 ((:I - 3.5) * :SQ.SZ)
>((:J - 3.5) * :SQ.SZ))
> (PRINT :I :J "Contains mditem (list :i :j) :CHESS_POS)
> ]
> ]
>END
>
>CREATE_ARRAY
>0 0 Contains 44 -350 -350
>0 1 Contains 44 -350 -250
>0 2 Contains 44 -350 -150
>0 3 Contains 44 -350 -50
>0 4 Contains 44 -350 50
>0 5 Contains 44 -350 150
>0 6 Contains 44 -350 250
>0 7 Contains 44 -350 350
>1 0 Contains 44 -250 -350
>1 1 Contains 44 -250 -250
>1 2 Contains 44 -250 -150
>1 3 Contains 44 -250 -50
>1 4 Contains 44 -250 50
>1 5 Contains 44 -250 150
>1 6 Contains 44 -250 250
>1 7 Contains 44 -250 350
>2 0 Contains 44 -150 -350
>2 1 Contains 44 -150 -250
>2 2 Contains 44 -150 -150
>2 3 Contains 44 -150 -50
>2 4 Contains 44 -150 50
>2 5 Contains 44 -150 150
>2 6 Contains 44 -150 250
>2 7 Contains 44 -150 350
>3 0 Contains 44 -50 -350
>3 1 Contains 44 -50 -250
>3 2 Contains 44 -50 -150
>3 3 Contains 44 -50 -50
>3 4 Contains 44 -50 50
>3 5 Contains 44 -50 150
>3 6 Contains 44 -50 250
>3 7 Contains 44 -50 350
>4 0 Contains 44 50 -350
>4 1 Contains 44 50 -250
>4 2 Contains 44 50 -150
>4 3 Contains 44 50 -50
>4 4 Contains 44 50 50
>4 5 Contains 44 50 150
>4 6 Contains 44 50 250
>4 7 Contains 44 50 350
>5 0 Contains 44 150 -350
>5 1 Contains 44 150 -250
>5 2 Contains 44 150 -150
>5 3 Contains 44 150 -50
>5 4 Contains 44 150 50
>5 5 Contains 44 150 150
>5 6 Contains 44 150 250
>5 7 Contains 44 150 350
>6 0 Contains 44 250 -350
>6 1 Contains 44 250 -250
>6 2 Contains 44 250 -150
>6 3 Contains 44 250 -50
>6 4 Contains 44 250 50
>6 5 Contains 44 250 150
>6 6 Contains 44 250 250
>6 7 Contains 44 250 350
>7 0 Contains 44 350 -350
>7 1 Contains 44 350 -250
>7 2 Contains 44 350 -150
>7 3 Contains 44 350 -50
>7 4 Contains 44 350 50
>7 5 Contains 44 350 150
>7 6 Contains 44 350 250
>7 7 Contains 44 350 350
>
>
>john wood wrote:
> >
> > I am trying to use 2 FOR loops to put in the values of an 8 x 8 array.
>I am
> > working with making a chess board/game and for each position I want to
>put
> > the turtle number, the x coordinate and the y coordinate. I am using 44
>as
> > a dummy turtle number.
> >
> > Here is my code:
> >
> > TO CREATE_ARRAY
> > MAKE "CHESS_POS ARRAY [8 8]
> > FOR "I 0 7 [FOR "J 0 7 [PRINT :I PRINT :J ASET :CHESS_POS [:I :J]
>[44
> > ((:I - 3.5) * :SQ.SZ) ((:J - 3.5) * :SQ.SZ)]
> > END
> >
> > When I try running this I get the following message:
> >
> > 0
> > 0
> > The procedure ASET needs a number as its input.
> > In function CREATE_ARRAY
> > \
> > Statement [FOR "I 0 7 [FOR "J 0 7 [PRINT :I PRINT :J ASET :CHESS_POS
>[" :\
> > I " :J] [44 ((:I - 3.5) * :SQ.SZ) ((:J - 3.5) * :SQ.SZ)]]]]
> >
> > The reason I put the print statements in the procedure was to show that
>:I
> > and :J were really numbers.
> >
> > Why am I getting an error message?
> >
> > Any help is greatly appreciated. In advance, THANK YOU.
> >
> > Could I have written the code as :
> >
> > TO CREATE_ARRAY
> > MAKE "CHESS_POS ARRAY [8 8]
> > FOR "I 0 7
> > [FOR "J 0 7
> > [ASET :CHESS_POS [:I :J] [44 ((:I - 3.5) * :SQ.SZ) ((:J - 3.5)
>*
> > :SQ.SZ)]
> > END
> >
> > ?
> >
> > _______________________________________________________________
> > Get Free Email and Do More On The Web. Visit http://www.msn.com
> > ---------------------------------------------------------------
> > Please post messages to the Logo forum to log...@gsn.org. Mail
> > questions about the list administration to log...@gsn.org. To
> > unsubscribe send unsubscribe logo-l to majo...@gsn.org.
>
>--
>===============================================================
>George Mills
>email: mi...@softronix.com
>http://www.softronix.com
>The www page contains some very powerful educational software.
>Our single most important investment is our kids.
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com
---------------------------------------------------------------
Please post messages to the Logo forum to log...@gsn.org. Mail
questions about the list administration to log...@gsn.org. To
unsubscribe send unsubscribe logo-l to majo...@gsn.org.
Bill
****************************************************************
Harvard Associates & makers of PC Logo and LogoPLUS
Terrapin Software Internet: in...@terrapinlogo.com
10 Holworthy Street phone: (617) 492-0660
Cambridge, MA 02138 USA fax: (617) 492-4610
World Wide Web: www.terrapinlogo.com
****************************************************************
---------------------------------------------------------------
Well in both your examples I count 5 left brackets total and 3 right brackets.
Could be a mail issue but that's what I received.
>
> I tried to part of the FOR loop on the next line and I got an error message
> needing more inputs. The FOR loop supports no increment if the increment is
> 1.
That's fine.
>
> Although the help and reference manual show brackets around the dimensions
> of the array, when I remove the brackets then I get an error message, that
> ASET requires more inputs.
You can use brackets if they contain constant values (not variables).
Like [8 8] or [3 5] is fine. But [:I :J] will not work. There are times
you do want [:I :J] but that's for more advanced programming.
Your solution with SENTENCE is the same as I provided with LIST.
But be careful there are some subtle differences between SENTENCE and LIST.
Sometimes you want a LIST of LIST's, you can't use SENTENCE when you want this.
show (LIST 1 2 3 (LIST 1 2))
[1 2 3 [1 2]]
show (SENTENCE 1 2 3 (SENTENCE 1 2))
[1 2 3 1 2]
In your example it did not matter. In my opinion you should get in the habit of
using LIST not SENTENCE for this type of application. When you want to merge
lists you use SENTENCE. When you want to build lists you use LIST.
Also note that SHOW, Shows the list where as PRINT, prints the contents of the
list. It's often clearer to use SHOW than PRINT when trying to debug.
Example of printing two lists
(show [1 2 3] [4 5])
[1 2 3] [4 5]
(print [1 2 3] [4 5])
1 2 3 4 5
You can see that print is sort of useless here.
>
> Is this a similar problem that I dealt with (SORRY, BUT I JUST DISCOVERED
> THE SOLUTION!)
>
> I had some difficulty with the PRINT part. When I put PRINT [:I :J],
> the result was :I :J when I was expecting number results. I then tried
> PRINT :I and I got a result, 0 before the error message. Then I put PRINT
> :J and on the next line I got another 0 before the error message. So my
> next concern was to put both I and J on the same line. When I put PRINT (SE
> :I :J), then I got '0 0' before the error message. As you might have
> figured out, I just realized I needed to do the same for the list for ASET.
>
> |
>
> \|/
>
> The program works with ASET :CHESS_POS (SE :I :J) (SE (44 ...)).
>
> The necessary change was to put the array position as a sentence, not in
> brackets, as my reference guide shows. Is this true of variables but works
> with numeric values? I don't know.
LIST will also work.
ASET :CHESS_POS (LIST :I :J) (LIST (44 ...))
<snip>
> > > ---------------------------------------------------------------
> > > Please post messages to the Logo forum to log...@gsn.org. Mail
> > > questions about the list administration to log...@gsn.org. To
> > > unsubscribe send unsubscribe logo-l to majo...@gsn.org.
> >
> >--
> >===============================================================
> >George Mills
> >email: mi...@softronix.com
> >http://www.softronix.com
> >The www page contains some very powerful educational software.
> >Our single most important investment is our kids.
>
> _______________________________________________________________
> Get Free Email and Do More On The Web. Visit http://www.msn.com
> ---------------------------------------------------------------
> Please post messages to the Logo forum to log...@gsn.org. Mail
> questions about the list administration to log...@gsn.org. To
> unsubscribe send unsubscribe logo-l to majo...@gsn.org.
--
===============================================================
George Mills
email: mi...@softronix.com
http://www.softronix.com
The www page contains some very powerful educational software.
Our single most important investment is our kids.