chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] redefining cons,car,cdr in SICP


From: David Steiner
Subject: [Chicken-users] redefining cons,car,cdr in SICP
Date: Fri, 3 Dec 2010 18:33:09 +0100

i'm reading SICP and practicing in chicken. in the book they redefine
cons, car and cdr using procedures:

(define (cons x y)
  (define (dispatch m)
    (cond ((= m 0) x)
          ((= m 1) y)
          (else (error "Argument not 0 or 1 -- CONS" m))))
  dispatch)
(define (car z) (z 0))
(define (cdr z) (z 1))

however it produces an error in chicken:
   Error: (caar) bad argument type: #<procedure (dispatch m)>

why doesn't it work?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]