[cl-faq] car and cdr naming
Justin Heyes-Jones
justinhj at gmail.com
Thu Jan 12 19:59:30 CST 2006
Figured I'd answer this one...
\faq{
\question{Why are CAR and CDR called that?}
\answer{
car and cdr are the fundamental accessors for the head of a list and
the rest of a list. Their names come from the names of two assembler
macros on the IBM 704 mainframe.
These macros were used to extract two memory addresses from a 36bit
register. car is an abbreviation of contents of address of register
whilst cdr is for contents of decrement of register.
The assembler macros ended up with a home in lisp itself since they
formed the basic computer operations on the 704 to perform what we can
refer to as first and rest.
car and cdr survive in modern common lisp mostly for nostalgia reasons
and also because of an interesting set of abbreviations they allow. By
forming new abbreviations such as cadr and caaddr we treat each a as a
car and each d as a cdr.
So cadr is an abbreviated form of (car (cdr lst)) and caaddr is an
abbreviation of (car (car (cdr (cdr lst)))
See wikipedia's entry for more
http://en.wikipedia.org/wiki/Cdr
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lispniks.com/pipermail/cl-faq/attachments/20060112/8337afaf/attachment.html
More information about the cl-faq
mailing list