[Tex/LaTex] What do \@nil, \@cdr and \@car mean

latex-basemacros

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 haven't seen any description about it on google and TeX.SX.

Best Answer

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

Related Question