In scheme these are valid functions:
(define (cons a d)
(lambda (x)(x a d)))
(define (car x)
(x (lambda (a d) a)))
If I try redo the same functions in Common Lisp I get an error
when running car1. The error being:
CAR1: symbol D has no value
[Condition of type SYSTEM::SIMPLE-UNBOUND-VARIABLE]
The CL code I try to run is this:
(defun cons1 (a d)
(lambda (m) (m a d)))
(defun car1 (x)
(x (lammda (a d) a)))
(car1 (cons1 'a 'b))
regards
-arne
Arne Hanssen wrote:
> In scheme these are valid functions:
> (define (cons a d)
> (lambda (x)(x a d)))
>
> (define (car x)
> (x (lambda (a d) a)))
>
> If I try redo the same functions in Common Lisp I get an error
> when running car1. The error being:
>
> CAR1: symbol D has no value
> [Condition of type SYSTEM::SIMPLE-UNBOUND-VARIABLE]
>
> The CL code I try to run is this:
>
> (defun cons1 (a d)
> (lambda (m) (m a d)))
>
> (defun car1 (x)
> (x (lammda (a d) a)))
>
> (car1 (cons1 'a 'b))
(defun cons1 (a d)
(lambda (x) (funcall x a d)))
(defun car1 (x)
(funcall x (lambda (a d) a)))
If you want to know why you have to say funcall here, google for
"Lisp-1" and "Lisp-2".
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/