[plt-scheme] cadr: expects argument of type <cadrable value>;
You are confusing mutable and immutable lists.
Jos
----- Original Message -----
From: "Derrick Wippler" <thrawn01 at gmail.com>
To: <plt-scheme at list.cs.brown.edu>
Sent: Thursday, January 14, 2010 5:38 PM
Subject: [plt-scheme] cadr: expects argument of type <cadrable value>;
> I'm new to Scheme so hopefully this will be simple to solve, I'm
> trying to compile the following project using mzscheme
>
> http://www.ida.liu.se/~tobnu/scheme2llvm/
>
> I resolved an issue with the current code using cons instead of mcons
> but now I have an issue I can't resolve.
>
> I'll paste the relevant code below
>
> ---------
> (define (definition-value exp)
> (if (symbol? (cadr exp))
> (caddr exp)
> (mcons 'lambda (mcons (cdadr exp) (cddr exp)))))
>
> (define (fix-list lst)
> (cond ((not (pair? lst)) (mcons lst '()))
> (else (mcons (car lst) (fix-list (cdr lst))))))
>
> (define exp `(llvm-define (and x y) (if x y (make-null))))
>
> (define f-lambda (definition-value exp))
>
> (define (lambda-parameters exp)
> (if (list? (cadr exp)) (cadr exp) (fix-list (cadr exp))))
>
> (lambda-parameters f-lambda)
> ----------
>
> The error for that final line is:
> cadr: expects argument of type <cadrable value>; given {lambda (x y) .
> ((if x y (make-null)))}
>
> This error confuses me as the following repl output will illustrate
>
>> (cadr `{lambda (x y) . ((if x y (make-null)))})
> (x y)
>
>> (cadr f-lambda)
> cadr: expects argument of type <cadrable value>; given {lambda (x y) .
> ((if x y (make-null)))}
>
> The error specifies the type cadr requires but does not explicitly
> describe the type of the given argument. My assumption therefore is
> scheme is NOT telling me the entire story, Can someone fill in the
> gaps?
>
> Thanks,
>
> Derrick J. Wippler
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
--------------------------------------------------------------------------------
Se certificó que el correo entrante no contiene virus.
Comprobada por AVG - www.avg.es
Versión: 9.0.725 / Base de datos de virus: 270.14.139/2620 - Fecha de la
versión: 01/14/10 08:35:00