[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (atom? '()) => #t



In article <1990Mar7.194937.1421@sun.soe.clarkson.edu>, jk0@sun.soe.clarkson.edu (Jason Coughlin) writes:
> Can someone explain the rationale behind treating '() as an atom?  It
> seems to me that it should be a pair:  it's the empty *list* not the
> empty *atom*.
> 

When you look at lists from a purely functional point of view then
any list is the result of CONS, whereas () is a primitive object,
thus an atom. A good example of this approach was given in Abelson,
Sussman and Sussman's book, where CONS, CAR and CDR are implemented
functionally as follows :-

(define (cons x y)
  (define (dispatch m)
    (cond ((= m 0) x)
	  ((= m 1) y)
	  (else (error "Arg not 0 nor 1 -- CONS" m))))
  dispatch)

(define (car z)(z 0))
(define (cdr z)(z 1))

As you can see () does not even appear anywhere in this
definition, it may be viewed as a constant which customarily
appears at the end of the sequencs of pairs (which we call a list).

Jacob	o | o
         \_/