LOGO-L> Re: SETPC 
Author Message
 LOGO-L> Re: SETPC

Quote:

> Hi,
> I'm a fortran/COBOL/C programmer trying to teach his daughter Logo.
> I understand pointers and indirection.
> 1. I do not understand why variable names must be preceeded by a double
> quote in the make command, and then by a colon in the print command.  Is
> there someplace (either the online documentation or Jim's book) that
> explains (from a programmer's perspective) how to create and manipulate
> variables?

The reason why it's different (definition and use) is because you WANT
it to be different. It's similar to the reason why Pascal uses :=
for assignment rather than =. After kids just got threw learning

a != a + 1

Programming comes along (Like C/FORTRAN) and does this

a = a + 1

This can be confusing for young programmers. So the idea is to make
it clear that it's not an equation but an assignment.

make "a :a + 1

That is, DEFINE a new variable A by using the current VALUE of A plus 1.

Quote:
> 2. Given the following sequence:
> make "a 255
> setpc [:a 0 0]
> why do I get the message:
> setpc doesnt like [:a 0 0] as input
> More to the point, how do I create continuously varying colors?

Your second problem is extremely common.

In C lingo you did this.

sprintf(foo, ":a 0 0");
setpc(foo);

But what you want is

sprintf(foo, "%d 0 0", :a);
setpc(foo);

Right?

To do this you need to build a new list with :a resolved

setpc (list :a 0 0)

Yes, parens are done differently also :-)

For someone that has never used Logo, Lisp or Scheme it's baffling
and it takes quite some time to appreciate. For someone that's never
programmed it's more intuitive (rules are more consistent and generally
simple).

My most Native language is C++ but I still LOVE to play in Logo.

Brian's books will give more technical information about Logo, apply
more of the advanced features of the language and is designed for older
students. Jim's books are more by example and geared towards younger
students and covers some of the unique features of MSWLogo.

Both are excellent with very different goals see URL's on MSWLogo's web page.

Quote:
> 3. In a nested "repeat" loop, is it correct to assume that "repcount"
> refers to the inner value in the inner loop and the outer value in the
> outer loop?  If I want to reference the outer value in the inner loop I
> assume I must capture it into a variable before the inner "repeat" (e.g.):
> make "outer repcount

Yes, you are correct.

Quote:
> Is there any syntax that will let me reference the outer repcount from the
> inner loop?

Yes, see Help on FOR. Although FOR, WHILE etc. are not technically
standard Logo they are mighty handy.

To get help on FOR enter

help "FOR

You sound like a C programmer for sure, getting his loop control understood.
Also study recursion for solving problems also.


See bottom of MSWLogo page on how to join and learn powerful
recursive techniques that even young programmers can grasp.

Quote:
> 4.  Why can I "print repcount", but must "print :a"?  What is the
> difference between those two variables that the "a" requires the colon?

repcount is a function that output the internal counter vs :a is a variable.

C uses ()'s to indicate a function, logo uses a bare name.

Great questions

Quote:

> Thanx,
> Marc

--
===============================================================

http://www.*-*-*.com/
The www page contains some very powerful educational software.
Our single most important investment is our kids.
---------------------------------------------------------------





Tue, 30 Apr 2002 03:00:00 GMT  
 LOGO-L> Re: SETPC

Quote:

> > Hi,
> > I'm a FORTRAN/COBOL/C programmer trying to teach his daughter Logo.
> > I understand pointers and indirection.
> > 1. I do not understand why variable names must be preceeded by a double
> > quote in the make command, and then by a colon in the print command.  Is
> > there someplace (either the online documentation or Jim's book) that
> > explains (from a programmer's perspective) how to create and manipulate
> > variables?

> This can be confusing for young programmers. So the idea is to make
> it clear that it's not an equation but an assignment.

> make "a :a + 1

> That is, DEFINE a new variable A by using the current VALUE of A plus 1.

Another way to think about it is something like:

make(&a, a+1)

make() changes the value of "a" pretty much life scanf()

and that is how I tried to teach pointers with Logo.

Quote:
> > 4.  Why can I "print repcount", but must "print :a"?  What is the
> > difference between those two variables that the "a" requires the colon?

        ; make the variable named random have the value 30
        make "random 30
        ; print the value of the variable random
        print :random
30
        ; print 30 again (not random at all)
        print :random
30
        ; print the word "random"
        print "random
random
        ; print the output of the random function
        print random
not enough inputs to random
        ; oops I forgot the argument
        print random 6
3
        ; please, another random number
        print random 6
4

Daniel

---------------------------------------------------------------





Wed, 01 May 2002 03:00:00 GMT  
 LOGO-L> Re: SETPC

Quote:

>> 1. I do not understand why variable names must be preceeded by a double
>> quote in the make command, and then by a colon in the print command.

Don't think "names must be preceded by quote in the make command."

Instead, think:  The first input to MAKE is *the name of* the variable
to which you want to assign a value.  That name is a word.  As in any
other context, you can use any expression whose value is a word.  So
for example

        make first butfirst [a b c] 3

will assign the value 3 to the variable B, without any quotation marks.

As for colons, the underlying issue is that in Logo the same word can
separately name a procedure and a variable, so there has to be a way
to distinguish a request to run the procedure from a request to find
the variable's value.  The colon indicates the latter.



Tue, 07 May 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. LOGO-L> Re: SETPC Question

2. LOGO-L> Apple logo/MSW Logo

3. LOGO-L> Reseach Machines Logo (RM LOGO)

4. WTD: 'ls -lR '->HTML code

5. LOGO-L> Welcome to logo-l

6. LOGO-L> Re: Dynamic scope in Logo

7. LOGO-L> INFO re SIG-LOGO

8. LOGO-L> Logo speed

9. LOGO-L> Logo foundation site

10. LOGO-L> Logo Workshops

11. LOGO-L> Logo for MAC

12. LOGO-L> Object Logo for PC

 

 
Powered by phpBB® Forum Software