CAR And CDR
car ( /ˈkɑr/) and cdr (/ˈkʌdər/ or /ˈkʊdər/) are primitive operations on cons cells (or "non-atomic S-expressions") introduced in the Lisp programming language. A cons cell is composed of two pointers; the car operation extracts the first pointer, and the cdr operation extracts the second.
Thus, the expression (car (cons x y))
evaluates to x
, and (cdr (cons x y))
evaluates to y
.
When cons cells are used to implement singly linked lists (rather than trees and other more complicated structures), the car operation returns the first element of the list, while cdr returns the rest of the list. For this reason, the operations are sometimes given the names first and rest or head and tail.
Read more about CAR And CDR: Etymology, Other Computer Languages
Famous quotes containing the word car:
“Fifty years from now, it will not matter what kind of car you drove, what kind of house you lived in, how much you had in your bank account, or what your clothes looked like, But the world may be a little better because you were important in the life of a child.”
—Anonymous. Quoted in The Winning Family, by Louise Hart, ch. 1 (1987)