Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (execute expr)
- (lambda (x)
- (let recur ((expr expr))
- (case expr
- ((x) x)
- ((+) +)
- ((-) -)
- ((*) *)
- ((/) /)
- (else
- (if (list? expr)
- (apply (recur (car expr)) (map recur (cdr expr)))
- expr))))))
- > (define foo (execute '(* (+ 1 x) (- x (* 2 3)))))
- > (foo 42)
- => 1548
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement