The language many of us learned to program with: a turtle with a pen that obeys
commands such as forward 100 or right 90. With repetitions and procedures
that call themselves you get all the way to fractals. It accepts commands in English and also in Spanish,
as in LogoWriter.
Ordered from the simplest to the hardest. Each one explains the new idea that appears; the button loads it into the program and draws it. Afterwards, try changing the numbers and see what happens: that is how you learn Logo.
The screen is 600 steps wide, with the origin at the center. Heading 0 points up and increases clockwise. Commands can be written with or without accents, in lowercase or uppercase, and separated by spaces or on different lines.
| Command | Short form or alias | In Spanish | What it does |
|---|---|---|---|
forward 50 | fd | avanza · av | Walks 50 steps in the direction it is facing; if the pen is down, it leaves a mark. |
back 50 | bk | retrocede · re | Walks backward without turning around. |
right 90 | rt | giraderecha · gd | Turns 90° clockwise, without moving from its place. |
left 90 | lt | giraizquierda · gi | Turns the other way, counterclockwise. |
penup · pendown | pu · pd | subelapiz · bajalapiz (sl · bl) | Lifts or lowers the pen: with the pen up it walks without drawing. |
penerase | goma | Whatever it travels over is erased. Drawing resumes with pendown. | |
repeat 4 [ … ] | repite | Repeats the commands in the brackets. repcount says which pass it is on (1, 2, 3…). | |
to square :side … end | para … fin | Defines a new procedure with its inputs (:side). Afterwards it is used like any other command: square 80. | |
if :n < 5 [ … ] | si | Does what is in the brackets only if the condition holds. ifelse cond [ … ] [ … ] chooses between two. | |
stop | alto | Ends the procedure it is in. It is what stops a recursion. | |
make "side 40 | haz | Stores a value in a variable; afterwards it is used as :side. | |
setpencolor "red | setpc | poncolor · poncl | Pen color: white, red, green, blue, yellow, orange, violet, lightblue, cyan, pink, gray, brown… or a number from 0 to 15. The Spanish color names also work. |
setbackground "blue | setbg | ponfondo · pf | Background color (clears the screen). |
setpensize 3 | grosor | Width of the stroke. | |
clearscreen | cs | borrapantalla · bp | Clears everything and takes the turtle to the center, facing up. |
home | centro | Goes back to the center (drawing, if the pen is down). | |
setxy 100 50 · setheading 45 | seth | ponpos · ponrumbo (pr) | Goes to a point, or points to a heading, without going through turns. |
hideturtle · showturtle | ht · st | ocultatortuga · muestratortuga (ot · mt) | Hides or shows the turtle. |
print :n | show | escribe · es | Shows a value below the program. |
random 10 · sqrt 2 · sin 30 · cos 30 | — | azar · raizcuadrada · sen · cos | Functions: a random integer from 0 to 9, the square root, sine and cosine in degrees. |
Calculations are written as in mathematics: :side / 2, :n - 1,
360 / :sides. A minus sign attached to the number and separated from what precedes it, as in dragon :n -1,
is a negative number, not a subtraction. Whatever follows a ; is a comment.