APPLY and FUNCALL

apply and funcall are alternative ways to call a function whose name is computed; their arguments are supplied in different ways, so that explicit construction of Lisp code is not required, as it is for eval.

(apply fn list-of-args) applies the function fn to the arguments in the list list-of-args. Both arguments of apply are first evaluated.


(setq myfun #'+)

(apply myfun '(2 3))  =  5

(funcall fn arg1 ... argn ) calls the function fn with the arguments arg1 ... argn . All arguments of funcall are evaluated.


(funcall (get (get object 'shape)
              'drawing-program)
         (get object 'position)
         (get object 'size))

Contents    Page-10    Prev    Next    Page+10    Index