tags:

views:

60

answers:

3

I am implementing an interpreter for the LISP defined in,

http://www.scribd.com/vacuum?url=http://www.ee.ryerson.ca/~elf/pub/misc/micromanualLISP.pdf

My problem is the paper states that a LIST is,

4. (LIST e1 ... en) is defined for each n to be 
   (CONS e1 (CONS ... (CONS en NIL))).

So when a read in a list from the user such as,

(QUOTE (B C D (E F)))

using the above structure it becomes,

(QUOTE B C D E F)

There is no way to differentiate nested lists it all becomes a giant chain of cons.

Am I missing something here?

+1  A: 
(QUOTE (B C D (E F)))
= (...  (CONS (E F) NIL))).
= (...  (CONS (CONS E (CONS F NIL)) NIL))).

which is different from

( ...(CONS D (CONS E (CONS F NIL))).
deinst
+3  A: 

(QUOTE (B C D (E F))) is

(CONS B (CONS C (CONS D (CONS (CONS E (CONS F NIL)) NIL))))

(QUOTE (B C D E F)) is

(CONS B (CONS C (CONS D (CONS E (CONS F NIL)) NIL)))

Or to put it another way:
(LIST D (LIST E F)) = (CONS D (CONS (LIST E F) NIL))
(LIST D E F) = (CONS D (LIST E F))

Gilles
A: 
(QUOTE (B C D (E F))) = (LIST B C D (LIST E F))
mathk