Copyright © University of Cambridge. All rights reserved.

'First Forward Into Logo 5: Pen Up, Pen Down' printed from http://nrich.maths.org/

Show menu

First Forward Into Logo
Previous: FF4

 

This article introduces the idea of a procedure. Procedures allow you to save instructions in LOGO, creating primitives of your own, which you can use elsewhere. Once you have "taught " LOGO what the word "PATTERN" means - it will remember what to do whenever you type in "PATTERN". Providing you save your procedure at the end of you session you can call it up again the next time you wish to do some work.


Consider the following procedure:
TO PATTERN
REPEAT 12 [PU FD 60 PD REPEAT 4 [FD 45 RT 90]PU BK 60 LT 30]
END

What do you think is happening?

The command PU means Pen Up and PD means Pen Down.

Try tracing out the instructions step by step:
* You have something to do - 12 times!
* In doing that something you have to repeat something else 4 times!
Strange ...

Type in the procedure and run it?
ring of squares
Were you right?

Now, try changing different parts of the procedure. Can you anticipate what is going to happen to your diagram in each case?

 


 

Next: FF6