[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Could anyone explain why example no. 4 is different from the others?
From: |
Philip Kaludercic |
Subject: |
Re: Could anyone explain why example no. 4 is different from the others? |
Date: |
Thu, 17 Aug 2023 10:41:23 +0000 |
Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:
> Could anyone explain why example no. 4 is different from the others?
> Example no. 1
>
> ,----
> | (append '(nil) '(nil) '(nil))
> `----
>
> ,----
> | (nil nil nil)
> `----
>
> Example no. 2
>
> ,----
> | (funcall 'append '(nil) '(nil) '(nil))
> `----
This is equivalent to example 1.
> ,----
> | (nil nil nil)
> `----
>
> Example no. 3
>
> ,----
> | (apply 'append '((nil) (nil) (nil)))
> `----
This is also equivalent to example 1.
> ,----
> | (nil nil nil)
> `----
>
> Example no. 4
>
> ,----
> | (apply 'append '(nil) '(nil) '(nil))
> `----
This is equivalent to
(funcall 'append '((nil) (nil) . (nil)))
or
(append '(nil) '(nil) nil)
because with apply, the last argument is used to call a function with
variadic arguments.
In general, (funcall 'foo a b c ...) is the same as (apply 'foo (list a
b c ...)).
> ,----
> | (nil nil)
> `----