next up previous
Contents Next: Some Primitive Functions Up: Basic Data Types Previous: Atoms


The second rule of evaluation concerns lists. The interpreter treats any list as containing the name of a function followed by the arguments to the function. Schematically then, a list is read like this:

(name-of-function first-argument second-argument ...)
For example, try the following:

>(+ 2 13 45)
In this case, the interpreter applied the function + to the evaluated arguments and return with the value 60. Since the numbers are predefined, eval finds values for all the arguments, and everyone is happy. You could also enter:

>(+ my-age 1)
This works fine because my-age is evaluated and the value 10 is found (assuming you did just what was described in the section above). However:

>(+ your-age 1)
will generate an error (unbound variable your-age).

Also, if you attempt to use something that is not a function, you will generate an error message. So, for example, typing

>(foo 1 3 4)
causes an error (undefined function foo), unless you had previously defined foo to be a function. (More on defining functions in a later chapter).

© Colin Allen & Maneesh Dhagat
November 1999