The turtle moves on a square canvas of size 600 pixels. The lower left
corner of the canvas is located at (-300,-100) and the upper right
corner is located at (300,500). The turtle is initially located at
(0,0) with heading 90 degrees. The initial pen state is down.
The remainder of the manual is devoted to a list of LOBO commands.
- (forward )
Evaluate <num expr>. Call the result d.
Move the turtle forward a distance d pixels. Example 1:
(forward 50)
moves the turtle forward a distance of 50.
- (right ) Evaluate <num expr>. Call
the result theta. Turn the turtle clockwise theta
degrees. Example 2:
((forward 50)
(right 90)
(forward 50)
)
moves the turtle forward 50 pixels, right 90 degrees, then forward 50
pixels. Note the final orientation of the turtle.
- (left ) Evaluate <num expr>. Call the
result theta. Turn the turtle counter-clockwise theta
degrees. Example 3:
((forward 50)
(left 90)
(forward 50)
)
turns the turtle counter-clockwise by 90 degrees.
- (backward )
Evaluate <num expr>. Call the result d. Move the turtle
backward a distance d pixels. Example 4:
((forward 50)
(right 90)
(backward 50)
)
moves the turtle forward 50, right 90 degrees, then backward 50. Note
the final orientation of the turtle.
- (penup) Raises pen, i.e., changes pen to the "up" state.
Note: The turtle's path is only drawn when the pen is in
the "down" state.
- (pendown) Lowers pen, i.e., changes pen to the "down"
state. Example 5:
(repeat 5
(penup)
(forward 5)
(pendown)
(forward 5)
)
draws a dashed line.
- (stop)
Terminates program.
- (if ) Evaluates <bool
expr>. If <bool expr> evaluates to true, executes
<then stmt block> The <then stmt block> can be either
a single statement, <stmt>, or a list of statements enclosed
in parentheses, (<stmt 1> <stmt 2> ... <stmt
N>). Example 6:
(if (= d 0)
(stop)
)
executes (stop) if d = 0. Example 7:
(if (< c 10)
((pendown)
(forward 100)
(stop)
)
)
executes ((pendown) (forward 100) (stop)) if c < 10.
- (if )
Evaluates <bool expr>. If <bool expr> evaluates to #t,
executes <then stmt block> otherwise executes <else stmt
block> Both <then stmt block> and <else stmt
block> can be either a single statement, <stmt>, or a list
of statements enclosed in parentheses, (<stmt 1> <stmt
2> ... <stmt N>). Example 8:
(if (< c 10)
((pendown)
(forward 100)
(stop)
)
((penup)
(backward 100)
(stop)
)
)
- (repeat ...)
Evaluate <num expr>. Call the result m.
Executes <stmt 1> <stmt 2> ... <stmt N>
m times. Example 9:
(repeat 5
(forward 50)
(right (/ 360 5))
)
draws a polygon with 5 sides.
- (to ( ...) ...)
Defines a procedure with name, <proc1>, and
parameters/local variables, <var 1> <var 2>...<var
N>. Example 10:
((to square (side)
(repeat 4
(forward side)
(right 90)
)
)
(square 50)
)
defines and calls a procedure which draws a square.
- ( ...)
Evaluates <expr 1> <expr 2> ... <expr N> and passes the
values as arguments to the procedure named, <proc 1>.
Example 11:
(square 100)
draws a square with sides of length 100.
- (make )
Within the body of a procedure, <proc>, evaluate
<expr> and assign the value to <var>. Note that
<var> must be in the parameter/local variable list for
<proc>. Example 12:
((to spiral(side angle max count)
(repeat max
(forward (* side count))
(right angle)
(make count (+ count 1))
)
)
(penup)
(forward 70)
(pendown)
(spiral 0.05 10 180 0)
)
increments count by 1 within the body of procedure, spiral.
- (color )
Evaluate <num expr>. Call the result hue. Change the
current pen color to hue where hue is an angle between 0 and
359 degrees. Red is 0 degrees, green is 120 degrees and blue is 240
degrees. Example 13:
((right 30)
(color 60)
(forward 100)
(right 120)
(color 300)
(forward 100)
(right 120)
(color 180)
(forward 80)
)
- (setxy )
Evaluate <num expr 1> and <num expr 2>.
Call the results X and Y. Move the turtle to
location (X,Y). Example 14:
((penup)
(setxy 50 50)
)
Example 15:
((to circle (h r)
(repeat 90
(color h)
(make r (* (/ h 360) 2 3.1416))
(setxy (* (cos r) 50) (+ (* (sin r) 50) 50))
(make h (+ h 4))
)
)
(penup)
(setxy 50 50)
(pendown)
(circle 0 0)
)
- (push)
Save the turtle's current state on the turtle stack.
The state consists of the turtle's location, heading,
pen state, and color.
- (pop)
Restore the turtle's state to the last state which was pushed (but has
not yet been popped) onto the turtle stack. Example 16:
((color 200)
(forward 25)
(push)
(color 0)
(right 45)
(forward 50)
(pop)
(forward 25)
)
-
Any Scheme expression which evaluates to a number.
-
Any Scheme expression which evaluates to a boolean.