CAR and CDR - Other Computer Languages

Other Computer Languages

Many languages (particularly functional languages and languages influenced by the functional paradigm) use a singly linked list as a basic data structure, and provide primitives or functions similar to car and cdr. These are named variously first and rest, head and tail, 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 cdr 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, for example, car and cdr become fst and snd when dealing with a pair type. Exact analogs of car and cdr are thus rare in other languages.

Read more about this topic:  CAR And CDR

Famous quotes containing the words computer and/or languages:

    What, then, is the basic difference between today’s computer and an intelligent being? It is that the computer can be made to see but not to perceive. What matters here is not that the computer is without consciousness but that thus far it is incapable of the spontaneous grasp of pattern—a capacity essential to perception and intelligence.
    Rudolf Arnheim (b. 1904)

    No doubt, to a man of sense, travel offers advantages. As many languages as he has, as many friends, as many arts and trades, so many times is he a man. A foreign country is a point of comparison, wherefrom to judge his own.
    Ralph Waldo Emerson (1803–1882)