Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
CAR and CDR
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Other computer languages== Many languages (particularly [[Functional programming|functional]] languages and languages influenced by the functional [[Programming paradigm|paradigm]]) use a [[Linked list|singly linked list]] as a basic data structure, and provide primitives or functions similar to <code>car</code> and <code>cdr</code>. These are named variously <code>first</code> and <code>rest</code>, <code>head</code> and <code>tail</code>, etc. In Lisp, however, the cons cell is not used only to build linked lists but also to build pair and nested pair structures, i.e. the <code>cdr</code> of a cons cell need not be a list. In this case, most other languages provide different primitives as they typically distinguish pair structures from list structures either typefully or semantically. Particularly in typed languages, lists, pairs, and trees will all have different accessor functions with different type signatures: in [[Haskell (programming language)|Haskell]], for example, <code>car</code> and <code>cdr</code> become <code>fst</code> and <code>snd</code> when dealing with a pair type. Exact analogues of <code>car</code> and <code>cdr</code> are thus rare in other languages. [[Clojure]] uses <code>first</code> instead of <code>car</code> and <code>next</code> or <code>rest</code> instead of <code>cdr</code>. [[Logo (programming language)|Logo]], on the other hand, uses <code>first</code> instead of <code>car</code> and <code>butfirst</code> instead of <code>cdr</code>.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)