Functions in Logo
Below are examples of programming user-defined functions in Logo.
Example: Functions in Logo
In the example below, the function name is greetings. After the END command, the function is called. No data is being passed into or out of the function.
TO greetings
print "Hello
print [It's nice to meet you.]
print [How are you doing?]
END
greetings
Output:
Hello
It's nice to meet you.
How are you doing?
Example: Functions in Logo
TO square :length
repeat 4 [ fd :length rt 90 ]
END
clearscreen
square 100
Example: Built-in Functions in Logo
The next example demonstrates a common built-in function on many programming languages. A random number can be generated and printed in Logo with this syntax.
print random 100