Created
August 7, 2014 00:52
-
-
Save ijp/fb1b62413ed858a1a0c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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