chapter  3
36 Pages

Defining Procedures

A Logo procedure is like a recipe, a description of how to do something. The SCRAMBLE procedure, for example, is a description of how to scramble eggs:

TO SCRAMBLE : EGGS rHONHARD : MILK HEAT.PAN 150 REPEAT : EGGS [CRACK] IF : MILK > 0 [MAKE "EGGS : EGGS + : MILK D POUR. IN.PAN STIR.AND.COOK : HOWHARD END

Though it is silly and probably not too useful to think of scrambling eggs with Logo, SCRAMBLE illustrates some important ideas about Logo procedures1:

1. Procedure names should say what they do: The name of a Logo procedure is a word. As we will see (Chapter 4), a word in Logo is any collection of letters, digits, and a few special characters like (We frequently use

in Logo names, like HEAT.PAN, to make them more readable.) The metaphor we use to describe writing procedures is teaching the genie a new word. From the genie’s point of view, it doesn’t matter what word we use. She would understand equally well if we called the scramble procedure XYZZY, TIMBUKTU or GAZORNENPLATZ, because the procedure is defined by the instructions contained within it.