Logo
1 Logo language
1.1 Program grammar
1.1.1 Statements
1.1.2 Procedures
1.1.3 Expressions
2 Built-in procedures
2.1 Turtle graphics
forward
fd
backward
bk
left
right
penup
pu
pendown
pd
home
clearscreen
cs
3 Examples
8.12

Logo🔗ℹ

    1 Logo language

      1.1 Program grammar

        1.1.1 Statements

        1.1.2 Procedures

        1.1.3 Expressions

    2 Built-in procedures

      2.1 Turtle graphics

    3 Examples

1 Logo language🔗ℹ

 #lang logo package: logo

1.1 Program grammar🔗ℹ

 

program

 ::= 

statement*

A Logo program is a sequence of statements separated by whitespace. Comments begin with ; and continue until the end of the line.

1.1.1 Statements🔗ℹ

 

statement

 ::= 

procedure-definition

 

  |  

procedure-call

 

  |  

if   test-expr   block

 

  |  

repeat   count-expr   block

 

block

 ::= 

[   statement*   ]

1.1.2 Procedures🔗ℹ

 

procedure-definition

 ::= 

to   identifier   parameter*   statement*   end

 

procedure-call

 ::= 

identifier   arg-expr

 

parameter

 ::= 

an identifier prefixed with :

1.1.3 Expressions🔗ℹ

 

expression

 ::= 

numeric literal

 

  |  

parameter

 

  |  

expression   operator   expression

 

operator

 ::= 

+  |  -  |  *  |  /  |  =  |  <  |  >

2 Built-in procedures🔗ℹ

2.1 Turtle graphics🔗ℹ

syntax

(forward d)

syntax

(fd d)

Move forward d units.

syntax

(backward d)

syntax

(bk d)

Move backward d units.

syntax

(left φ)

Turn left (anticlockwise) φ degrees.

syntax

(right φ)

Turn right (clockwise) φ degrees.

syntax

(penup)

syntax

(pu)

Raise the turtle’s pen so that lines are not drawn when moving.

syntax

(pendown)

syntax

(pd)

Lower the turtle’s pen to draw lines.

syntax

(home)

Return to the origin in a straight line.

syntax

(clearscreen)

syntax

(cs)

Clear the screen.

3 Examples🔗ℹ

The file sierpinski.rkt in this package shows how to draw a Sierpinski triangle using turtle graphics.