Newtro Logo
Logo is the programming language that put a turtle on the screen in 1967. Type a command at the ? prompt and the turtle carries it out. Teach it new words with TO, and it remembers them next time you visit.
? FD 100
This terminal needs JavaScript to run.
Try a program
Each one runs in the terminal above. Read the code, run it, then change a number and see what happens.
-
A square
Four steps forward, four quarter turns.
CS REPEAT 4 [FD 120 RT 90] -
A star
Turn 144 degrees five times and the lines cross into a star.
CS SETPC 6 REPEAT 5 [FD 200 RT 144] -
Spinning squares
A loop inside a loop, with a new color on every turn.
CS SETPENSIZE 2 REPEAT 12 [ SETPC REPCOUNT REPEAT 4 [FD 110 RT 90] RT 30 ] -
A square spiral
A procedure that calls itself, growing a little each time.
TO SPIRAL :SIZE IF :SIZE > 240 [STOP] FD :SIZE RT 91 SPIRAL :SIZE + 3 END CS SETPC 3 SPIRAL 2 -
A tree
Every branch is a smaller tree. This is recursion.
TO TREE :SIZE IF :SIZE < 6 [STOP] FD :SIZE LT 25 TREE :SIZE * 0.7 RT 50 TREE :SIZE * 0.7 LT 25 BK :SIZE END CS SETPC 2 PU BK 190 PD TREE 110 -
A snowflake
The Koch curve: each line becomes four smaller lines.
TO SIDE :SIZE :DEPTH IF :DEPTH = 0 [FD :SIZE STOP] SIDE :SIZE / 3 :DEPTH - 1 LT 60 SIDE :SIZE / 3 :DEPTH - 1 RT 120 SIDE :SIZE / 3 :DEPTH - 1 LT 60 SIDE :SIZE / 3 :DEPTH - 1 END CS SETPC 11 PU SETXY -150 90 PD SETH 90 REPEAT 3 [SIDE 300 3 RT 120] -
Flower of circles
ARC and CIRCLE draw curves around the turtle.
CS HT FOR [I 1 18] [ SETPC 1 + MODULO :I 6 PU FD 60 PD CIRCLE 60 PU BK 60 RT 20 ] PD ST -
Our wordmark
NEWTRO is a procedure too. Type PO "NEWTRO to read it.
CS NEWTRO
Everything the turtle understands
Short forms are in brackets. Commands work in upper or lower case. The turtle starts in the middle facing up, and 0 degrees is straight up.
Moving
- FORWARD 100 (FD)
- Move forward 100 steps.
- BACK 50 (BK)
- Move backward.
- RIGHT 90 (RT)
- Turn clockwise by degrees.
- LEFT 45 (LT)
- Turn counterclockwise.
- HOME
- Return to the middle, facing up.
- SETXY 50 -20
- Go straight to a point.
- SETHEADING 180 (SETH)
- Face a direction.
- ARC 180 50
- Draw part of a circle around the turtle.
- CIRCLE 40
- Draw a full circle around the turtle.
Pen and screen
- PENUP (PU)
- Move without drawing.
- PENDOWN (PD)
- Draw again.
- PENERASE (PE)
- Rub out lines as you move.
- SETPENCOLOR 4 (SETPC)
- A color number, a name like "RED, or [R G B] from 0 to 255.
- SETPENSIZE 3
- Make the line thicker.
- SETBACKGROUND 1 (SETBG)
- Change the screen color.
- CLEARSCREEN (CS)
- Wipe the screen and go home.
- HIDETURTLE (HT)
- Hide the turtle. SHOWTURTLE (ST) brings it back.
- LABEL "HELLO
- Write text where the turtle is.
- SPEED 10
- From 1, slow, to 10, fast. 0 is instant.
Repeating and deciding
- REPEAT 4 [ ... ]
- Run the list a number of times. REPCOUNT says which time it is.
- FOR [I 1 10 2] [ ... ]
- Count from 1 to 10 in steps of 2.
- IF :X > 5 [ ... ]
- Run the list only when the test is true.
- IFELSE test [ ... ] [ ... ]
- Choose between two lists.
- WHILE [test] [ ... ]
- Keep going while the test is true.
- FOREVER [ ... ]
- Keep going until you press Esc.
- WAIT 60
- Pause. 60 is one second.
Teaching new words
- TO SQUARE :SIZE ... END
- Define a procedure with inputs. Type it over several lines.
- STOP
- Leave the procedure now.
- OUTPUT value (OP)
- Give a value back to whoever asked.
- MAKE "SIDE 50
- Store a value. Read it back with :SIDE.
- LOCAL "X
- Keep a variable inside one procedure.
- POTS
- List your procedures. PO "NAME shows one.
- ERASE "NAME (ER)
- Forget a procedure. ERALL forgets them all.
Numbers and words
- + - * / = < >
- Arithmetic and comparisons.
- PRINT SUM 2 3 (PR)
- Show a result. SHOW keeps list brackets.
- RANDOM 10
- A whole number from 0 to 9.
- SQRT, POWER, SIN, COS
- Math, with angles in degrees.
- INT, ROUND, ABS, MODULO
- Tidy up numbers.
- FIRST, LAST, BUTFIRST, ITEM
- Take apart words and lists.
- LIST, SENTENCE, WORD, PICK
- Build them up, or choose at random.
The terminal
- HELP
- A quick reminder.
- Up and down arrows
- Bring back earlier commands.
- Esc
- Stop a running program.
- Paste
- Paste a whole program to run it at once.
- CLEARTEXT (CT)
- Clear the text lines.
- GAMES
- What else we're making.
Pen colors
- 0 black
- 1 blue
- 2 green
- 3 cyan
- 4 red
- 5 magenta
- 6 yellow
- 7 white
- 8 brown
- 9 tan
- 10 forest
- 11 aqua
- 12 salmon
- 13 purple
- 14 amber
- 15 gray
Why a turtle?
Wally Feurzeig, Seymour Papert and Cynthia Solomon created Logo in 1967 so children could learn by making things. The turtle started as a small robot that crawled across the floor with a pen. It moved onto screens, and into school computer labs everywhere.
Our puzzle game One Command Ahead grew from that same idea: a few clear instructions, a very literal machine, and the fun of watching your plan play out.