Apply takes its first argument and applies it as a function to the list of items making up the last. For example:
>(apply '* '(1 2 3 4)) 24You can imagine this being obtained by constructing the list (* 1 2 3 4) and evaluating the resulting list, although this is not strictly what happens since apply is a function, not a macro. Apply also allows intermediate arguments between the first and the last (see appendix) but the last argument is required to be a list.
Apply can also be used in conjunction with lambda lists. For example:
>(apply '(lambda (x y) (* x y)) '(45 67)) 3015If this does not seem particularly useful to you, think about how it can be used to construct complex programs on the fly.
© Colin Allen & Maneesh Dhagat