Re: what's the meaning of "car","cdr","cons" in tree's algorithm?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jim (me_at_privacy.net)
Date: 06/06/04


Date: Sun, 06 Jun 2004 15:32:25 GMT

On Tue, 20 Apr 2004 11:37:46 +0200, Anders Eriksson wrote:

> Hello!
>
> On Tue, 20 Apr 2004 17:06:12 +0800, hostran wrote:
> <snip>
>> there is "/* address of <car> */" & "/* address of <cdr> */" , but I don't
>> know what's the meanning of "car" , "cdr" & "cons"?
>>
>
> Whoa, a flashback from the days when I programmed in Lisp!
>
> You can read more about this here:
> http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_25.html
>
> To summarize (since I don't know exactly how the tree is created this is my
> guess): cons is a struct that contains two pointer, The first pointer is
> called 'car' and points to a cons on the left side of the tree and the
> second pointer is called 'cdr' and points to a cons on the right side of
> the tree.
> (left and right side may be switched)
>
> // Anders

>From my days of MacLisp:

CAR = Contends of the Address Register
CDR = Contends of the Data Register

General usage is the CAR pointed to the first element on the list and
CDR pointed to the rest of the list.

-- 
Quidquid latine dictum sit, altum viditur.


Relevant Pages