Example: Create a Square in Logo
forward(25) right(90) forward(25) right(90) forward(25) right(90) forward(25) right(90)
Example: Functions in Logo
In this program, the function is created first. The first line that runs, however, is clearscreen, which cleas the computer screen. The, the square function is called and the value 100 passed into it. The TO line accepts 100 in as and assigns it to the :length variable. Then, the repeat command is run to perform FD (move turtle forward) 100 pixels then turn 90 degrees and repeat this 4 times. This creates box/square.
TO square :length repeat 4 [ fd :length rt 90 ] END clearscreen square 100