[taos-glug] nil vs '() using Guile and PLT Scheme

  • From: Philip Ansteth <pansteth@xxxxxxxxxxx>
  • To: taos-glug@xxxxxxxxxxxxx
  • Date: Thu, 14 Aug 2003 14:14:12 -0600

I'm not sure why, but Guile wants you to use '() instead
of nil.  For example, in the first version of scale-list
in the section headed "Mapping of lists",  try '() instead of
nil.

Under PLT Scheme, nil doesn't work at all.  But '() does work.


For example, using Guile,

(define (scale-list items factor)
  (if (null? items)
      nil
      (cons (* (car items) factor) (scale-list (cdr items) factor))))

(scale-list (list 1 2 3 4 5) 10)

yields
(10 20 30 40 50 . nil)

But, changing nil to '(), the following.

(define (scale-list items factor)
  (if (null? items)
      '()
      (cons (* (car items) factor) (scale-list (cdr items) factor))))

(scale-list (list 1 2 3 4 5) 10)

yields
(10 20 30 40 50)

Using PLT Scheme (= mzScheme?) on my Windows laptop, nil doesn't work at all,
giving the message:  "reference to undefined identifier: nil"


Other related posts: