Created
November 7, 2019 21:34
-
-
Save chelseatroy/9cf6e59972e8b5a2ea24493d4fe6b603 to your computer and use it in GitHub Desktop.
Succeed or Fail
This file contains hidden or 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
(define (seval sexp succeed fail env) | |
(cond ((primitive? sexp) sexp) | |
((symbol? sexp) (succeed (lookup-environment env sexp) fail)) | |
; Special forms | |
((define? sexp) (seval-define sexp env)) | |
((if? sexp) (succeed (seval-if sexp env) fail) | |
((lambda? sexp) (succeed (seval-lambda sexp env) fail)) | |
; Procedure application | |
((list? sexp) (sapply sexp env)) | |
(else (error "Bad expression"))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment