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:
For example, try the following:(name-of-function first-argument second-argument ...)
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:> (+ 2 13 45) 60
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:> (+ my-age 1) 11
will generate an error (unbound variable your-age).> (+ your-age 1)
Also, if you attempt to use something that is not a function, you will generate an error message. So, for example, typing
causes an error (undefined function foo), unless you had previously defined foo to be a function. (More on defining functions in a later chapter).> (foo 1 3 4)
© Colin Allen & Maneesh Dhagat