Skip to content

Instantly share code, notes, and snippets.

@wat-aro
Created March 24, 2016 13:55
Show Gist options
  • Save wat-aro/398004a3df4a5d6e26dc to your computer and use it in GitHub Desktop.
Save wat-aro/398004a3df4a5d6e26dc to your computer and use it in GitHub Desktop.
(define (eval exp env)
(cond ((self-evaluating? exp) exp)
((variable? exp) (lookup-variable-value exp env))
((quoted? exp) (text-of-quotation exp))
((assignment? exp) (eval-assignment exp env))
((definition? exp) (eval-definition exp env))
((if? exp) (eval-if exp env))
((lambda? exp)
(make-procedure (lambda-parameters exp)
(lambda-body exp)
env))
((let? exp) (eval (let->combination exp) env))
((let*? exp) (eval (let*->nested-lets exp) env))
((letrec? exp) (eval (letrec->let exp) env)) ;;letrecを追加
((begin? exp)
(eval-sequence (begin-actions exp) env))
((cond? exp) (eval (cond->if exp) env))
((and? exp) (eval (and->if exp) env))
((or? exp) (eval (or->if exp) env))
((application? exp)
(my-apply (eval (operator exp) env)
(list-of-values (operands exp) env)))
(else
(error "Unknown expression type --EVAL" exp))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment