all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Could anyone explain why example no. 4 is different from the others?
@ 2023-08-17  3:15 Rodrigo Morales
  2023-08-17  4:32 ` tomas
  2023-08-17 10:41 ` Philip Kaludercic
  0 siblings, 2 replies; 3+ messages in thread
From: Rodrigo Morales @ 2023-08-17  3:15 UTC (permalink / raw)
  To: help-gnu-emacs

 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))
`----

,----
| (nil nil nil)
`----

Example no. 3

,----
| (apply 'append '((nil) (nil) (nil)))
`----

,----
| (nil nil nil)
`----

Example no. 4

,----
| (apply 'append '(nil) '(nil) '(nil))
`----

,----
| (nil nil)
`----



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Could anyone explain why example no. 4 is different from the others?
  2023-08-17  3:15 Could anyone explain why example no. 4 is different from the others? Rodrigo Morales
@ 2023-08-17  4:32 ` tomas
  2023-08-17 10:41 ` Philip Kaludercic
  1 sibling, 0 replies; 3+ messages in thread
From: tomas @ 2023-08-17  4:32 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

On Thu, Aug 17, 2023 at 03:15:50AM +0000, Rodrigo Morales wrote:
>  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))
> `----
> 
> ,----
> | (nil nil nil)
> `----
> 
> Example no. 3
> 
> ,----
> | (apply 'append '((nil) (nil) (nil)))
> `----
> 
> ,----
> | (nil nil nil)
> `----
> 
> Example no. 4
> 
> ,----
> | (apply 'append '(nil) '(nil) '(nil))
> `----
> 
> ,----
> | (nil nil)
> `----

Because your example number three is actually four nils. We
just can't see the fourth :)

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Could anyone explain why example no. 4 is different from the others?
  2023-08-17  3:15 Could anyone explain why example no. 4 is different from the others? Rodrigo Morales
  2023-08-17  4:32 ` tomas
@ 2023-08-17 10:41 ` Philip Kaludercic
  1 sibling, 0 replies; 3+ messages in thread
From: Philip Kaludercic @ 2023-08-17 10:41 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: help-gnu-emacs

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)
> `----



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-17 10:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-17  3:15 Could anyone explain why example no. 4 is different from the others? Rodrigo Morales
2023-08-17  4:32 ` tomas
2023-08-17 10:41 ` Philip Kaludercic

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.