Next: Procedures
Up: Conventions adopted by XLOGO
Previous: Conventions adopted by XLOGO
Contents
Index
The LOGO language allows certain events to be triggered by internal
commands - these commands are called primitives. Each primitive
may have a certain number of parameters which are called arguments.
For example, the primitive cs , which clears the screen,
takes no arguments, while the primitive sum takes two arguments.
print sum 2 3 will return 5.
LOGO arguments are of three kinds:
- Numbers: some primitives expect numbers as an argument: fd
100 is an example.
- Words: Words are marked by an initial ". An example
of a primitive which can take a word argument is print. print
"hello returns hello. Note that if you forget the
", the interpreter will return an error message. In effect,
print expects the argument, or for the interpreter, hello
does not represent anything, since it is not a number, a word, a list,
or an already defined procedure.
- Lists: These are defined between brackets.
Numbers are treated in some instances as a numeric value (eg: fd
100), and in others as a word (eg: print empty? 12 writes
false).
Several primitives have a general form, it means they could be used with an undefined number of arguments. All those primitives are on the table below:
print |
sum |
product |
or |
and |
list |
sentence |
word |
To notice to the interpreter that those primitive will be used in their general form, we have to write our command into parenthesis, look at those examples below:
print (sum 1 2 3 4 5)
15
(list [a b] 1 [c d])
I don't know what to do with [[a b] 1 [c d]]?
if (and 1=1 2=2 8=5+3) [fd 100 rt 90]
Next: Procedures
Up: Conventions adopted by XLOGO
Previous: Conventions adopted by XLOGO
Contents
Index
Loïc
2008-06-08