From: Luis M Ortega
Subject: of lists and conses
Date: 
Message-ID: <3bf907e5$0$233$ba620e4c@news.skynet.be>
Hello, world...

I am trying (yes !) to learn LISP.  On conses and lists, the tutorials I 
found say : 

x x x x x x x x

(clcl 2nd ed)
"A list is recursively defined to be either the empty list or a cons whose 
cdr component is a list."

From this sentence I conclude that a list cannot be composed of just one 
element.
Right ?

x x x x x x x x

(Geoffrey J. Gordon)

"Lists

You can build many structures out of conses. Perhaps the simplest is a 
linked list: the car of each cons points to one of the elements of the 
list, and the cdr points either to another cons or to nil."

Does it really means car POINTS to an element of the list ?

x x x x x x x x

thanks.

Luis 

From: Frode Vatvedt Fjeld
Subject: Re: of lists and conses
Date: 
Message-ID: <2hbshy51gk.fsf@dslab7.cs.uit.no>
Luis M Ortega <······@nospam.com> writes:

> From this sentence I conclude that a list cannot be composed of just
> one element.

That depends on the exact meaning of your words. A list contains as
many elements as it has cons cells, and a list built up of one cons
cell is certainly possible (It will have a NIL cdr and and arbitrary
car value that is the lists single element). If you mean that a list
can't be composed of just one object (that isn't a cons or nil; i.e an
atom), then you are right.

> Does it really means car POINTS to an element of the list ?

No, it means that the car holds the value that is an element of the
list. There are no pointer values in lisp.

-- 
Frode Vatvedt Fjeld
From: Kenny Tilton
Subject: Re: of lists and conses
Date: 
Message-ID: <3BF91D5A.F494BD2A@nyc.rr.com>
Luis M Ortega wrote:
> 
> Hello, world...
> 
> I am trying (yes !) to learn LISP.  On conses and lists, the tutorials I
> found say :
> 
> x x x x x x x x
> 
> (clcl 2nd ed)
> "A list is recursively defined to be either the empty list or a cons whose
> cdr component is a list."
> 
> From this sentence I conclude that a list cannot be composed of just one
> element.
> Right ?

No, it says the cdr of a cons is a list, but don't forget that that list
can be the empty list. So a list of one thing is a cons whose car points
to the thing and whose cdr is nil (the empty list).

> 
> x x x x x x x x
> 
> (Geoffrey J. Gordon)
> 
> "Lists
> 
> You can build many structures out of conses. Perhaps the simplest is a
> linked list: the car of each cons points to one of the elements of the
> list, and the cdr points either to another cons or to nil."
> 
> Does it really means car POINTS to an element of the list ?

Not sure what you are asking, but maybe this is a source of confusion:

The /function/ CAR applied to a cons cell returns the thing pointed to
by the car of a cons cell. ie, we use the word CAR in two ways, to refer
to:

  one of the pointers in a cons cell

  a function returning the thing pointed to bythe car of a cons cell

kenny
clinisys
From: Kent M Pitman
Subject: Re: of lists and conses
Date: 
Message-ID: <sfwg07a3di5.fsf@shell01.TheWorld.com>
Luis M Ortega <······@nospam.com> writes:

Answering your questions in the opposite order because my second answer
relies on the first.

> (Geoffrey J. Gordon)
>
> "Lists
> 
> You can build many structures out of conses. Perhaps the simplest is a 
> linked list: the car of each cons points to one of the elements of the 
> list, and the cdr points either to another cons or to nil."
> 
> Does it really means car POINTS to an element of the list ?

Lisp is all pointers.  Or none.  We don't use a special pointer type
because we consider all objects to be pointed to.  When we talk
"pointer to the symbol FOO" we are not adding an indirection but
merely emphasis.  It means the same as "the symbol FOO".  When we say
"the car POINTS TO" an object that's the same as saying "the car IS"
that object.

 (A . B)

is a cons whose car is the symbol A and whose cdr is the symbol B.
In memory this generally looks like a packed pair of pointers where one
pointer addresses the symbol A and the other the symbol B.

 +---+---+
 |   |   |
 | * | * |
 | | | | |
 +-|-+-|-+
   |   |
   v   v
   A   B

> (clcl 2nd ed)

"cltl"

> "A list is recursively defined to be either the empty list or a cons whose 
> cdr component is a list."
> 
> From this sentence I conclude that a list cannot be composed of just one 
> element.
> Right ?


A list of no elements is NIL, also possible to write as ().
NIL is not a cons.  It is an atom.  (An atom is, for historical reasons,
just another name for a non-cons.)  

A list of one element is something like (X) and uses exactly one cons.

 +---+---+
 |   |   |
 | * | * |
 | | | | |
 +-|-+-|-+
   |   |
   v   v
   X   NIL

A list of two elements is something like (X Y) and uses exactly two conses.

 +---+---+
 |   |   |
 | * | * |
 | | | | |
 +-|-+-|-+
   |   |
   v   |
   X   v
      +---+---+
      |   |   |
      | * | * |
      | | | | |
      +-|-+-|-+
	|   |
	v   v
	Y   NIL

What may confuse you is that you may have thought a list had to be a CONS.
Not so.  The type LIST is a union type of the disjoint types NULL (whose 
only set member is NIL, a regular symbol whose name is "NIL", and also by
special exception designated to represent the empty list), and of the 
type CONS (which contains all conses).  So the empty list is not a cons, 
but IS a list.  I hope that helps.