Logo programs are usually collections of small procedures. Generally, procedures are defined by writing them in a text editor. The special word to is followed by the name of the procedure. Subsequent lines form the procedure definition. The word end signals that you're finished.
In our turtle graphics example we defined a procedure to draw a square
to square
repeat 4 [forward 50 right 90]
end
and used it as a subprocedure of another procedure
to flower
repeat 36 [right 10 square]
end
Similarly, flower could be a building block of something larger
to garden
repeat 25 [set-random-position flower]
end
No, set-random-position is not a primitive, but random is and so is setposition (or setpos or setxy). Or you could write set-random-position using forward and right with random.
Once a Logo procedure is defined it works like the Logo primitives. In fact, when you look at Logo programs there's no way of knowing which words are primitives and which are user-defined unless you know that particular Logo implementation. In our language sample we used the procedure pick to randomly select an item from a list, for example in the procedure who.
to who
output pick [Sandy Dale Dana Chris]
end
In some versions of Logo pick is a primitive while in others you have to write it yourself. Who would look and work the same way in either case.
Logo allows you to build up complex projects in small steps. Programming in Logo is done by adding to its vocabulary, teaching it new words in terms of words it already knows. In this way it's similar to the way people learn spoken language.