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
7.7

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.