Skip to content

Instantly share code, notes, and snippets.

@ijp
Created August 7, 2014 00:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ijp/fb1b62413ed858a1a0c6 to your computer and use it in GitHub Desktop.
Save ijp/fb1b62413ed858a1a0c6 to your computer and use it in GitHub Desktop.
(use-modules (sxml transform))
(define (subst var val exp)
(cond ((pair? exp)
(cons (subst var val (car exp))
(subst var val (cdr exp))))
((eqv? var exp) val)
(else exp)))
(define *env*
`((+ . ,(lambda (tag . vals) (apply + vals)))
(* . ,(lambda (tag . vals) (apply + vals)))
(let *macro* . ,(lambda (tag var val body)
(subst var val body)))
(*text* . ,(lambda (tag val) val))))
(define (toy-eval exp)
(pre-post-order exp *env*))
(toy-eval
'(let x 10
(+ x x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment