ANSI Common Lisp. Why I get an other answer in the last case?
(list 1 2 3 nil) ; (1 2 3 nil)
(funcall (function list) 1 2 3 nil) ; (1 2 3 nil)
(apply (function list) '(1 2 3 nil)) ; (1 2 3 nil)
(apply (function list) 1 2 3 nil) ; (1 2 3)
ANSI Common Lisp. Why I get an other answer in the last case?
(list 1 2 3 nil) ; (1 2 3 nil)
(funcall (function list) 1 2 3 nil) ; (1 2 3 nil)
(apply (function list) '(1 2 3 nil)) ; (1 2 3 nil)
(apply (function list) 1 2 3 nil) ; (1 2 3)
APPLY
expects as arguments:The function will basically be called with the result of
(list* 0-arg ... n-arg argument-list)
Note that
(list* '(1 2 3))
evaluates to just(1 2 3)
.The arguments are called spreadable argument list in Common Lisp.
APPLY
uses such a spreadable argument list by design. For example(... 1 2 3 '(4 5))
. WithFUNCALL
you have to write the arguments as usual:(... 1 2 3 4 5)
.APPLY
has a single purpose in Common Lisp: it allows functions to be called with computed argument lists. To make that a bit more convenient, this idea of the spreadable argument list has been used. It works the same for example in Emacs Lisp.Imagine that you have a list of arguments and you want to add two arguments in front.