schemeevalchicken-scheme

Just eval first symbol (CHICKEN Scheme)


How can I evaluate an s-expression only by the first term?

(define (fn x y) (print x) (print y))
(eval '(fn a b))

I am trying to evaluate something like this on a bigger expression but the interpreter is complaining that a and b variables don't exist (unbound variable a).

Is there something I can do to leave symbols as they are?

I have been trying to find information about this but I can't find it anywhere.


Solution

  • How about the following?

    (let ((expr '(fn a b)))
      (cons (eval (car expr)) (cdr expr)))
    

    But please note that if you have to rely on eval, you're almost certainly doing things wrong.