User-defined functions can be included in new function definitions. For example:
It is worth paying attention to what happens when fourth-power is called. During the computation, the variable ``x'' gets assigned as many as four times. First, x is bound to 2, which is its local value for the function fourth-power. Fourth-power evaluates (square (square 2)), which means that square is called once with the argument 2, and again with the argument 4. Each time square is called, a local version of x is bound to the appropriate value. Finally, x is restored to whatever global value it previously had.> (defun fourth-power (x) (square (square x))) FOURTH-POWER > (fourth-power 2) 16
© Colin Allen & Maneesh Dhagat