previous | index | next

Using the apply Procedure

Use apply when you have the arguments to a procedure bundled up in an argument list (like the list subs in answer-by-pattern).

Suppose argument-list has the form

          (arg1 arg2 ... argn)
Then
          (apply procedure argument-list)
has the same effect as
          (procedure arg1 arg2 ... argn)
Compare
          (+ 3 5 8) ⇒ 16
and
          (apply + '(3 5 8)) ⇒ 16

previous | index | next