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)
APPLYexpects 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.
APPLYuses such a spreadable argument list by design. For example(... 1 2 3 '(4 5)). WithFUNCALLyou have to write the arguments as usual:(... 1 2 3 4 5).APPLYhas 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.