# What do \@nil, \@cdr and \@car mean

Today I came across these three commands:

\@nil
\@cdr
\@car


Some are mentioned here and here, but I didn't get the idea of it. It seems to have to do with the macro character.

• I retagged from tex-core to latex-base as these are latex macros – David Carlisle Feb 13 '17 at 22:01
• This question explains them quite well: Lisp relics in LaTeXe logo – Alan Munn Feb 13 '17 at 22:02
• @AlanMunn ooh it does but this one has a better title – David Carlisle Feb 13 '17 at 22:03
• That's probably the reason I haven't found it – MaestroGlanz Feb 13 '17 at 22:04

the names come from lisp.

In lisp, car returns the head of a list, cdr returns the tail of a list and nil is an empty list.

in latex

\def\@car#1#2\@nil{#1}
\def\@cdr#1#2\@nil{#2}


(\@nil is not defined at all)

so

\@car abc\@nil


expands to a

and

\@cdr abc\@nil


expands to bc

• In expl3 lingo, \tl_head:n {abc} and \tl_tail:n {abc} – egreg Feb 13 '17 at 22:02
• But how does this work, if \@nil is undefined. Why is there no undefined error? – MaestroGlanz Feb 13 '17 at 22:02
• @MaestroGlanz tokens only make an undefined error if you try to expand them. tokens used to delimit a macro argument are not expanded, try \def\foo#1\wibblethingy{hello #1}...\foo Maestro\wibblethingy – David Carlisle Feb 13 '17 at 22:06
• @egreg we should put in a change request \tl_car:n and tl_cdr:n to honour the cultural heritage – David Carlisle Feb 13 '17 at 22:08
• Aaaaah. Good to know. – MaestroGlanz Feb 13 '17 at 22:08