If I have a function and also a list of arguments, I can use apply
like this:
(apply func args)
For example:
(apply + '(1 2 3))
Now, if I define the function func
and a list of arguments args
as follows:
(define func +)
(define args '(1 2 3))
why then doesn't the following work to run the function:
(append (list func) args)
(cons func args) ; same thing
; (#<procedure:+> 1 2 3)
I would think the append
would create (+ 1 2 3)
just as (append '(1) '(2 3))
creates (1 2 3)
.
Why doesn't that occur, and is there a way to use append
to 'act like' the apply
, as I'm trying to do above?