Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created November 7, 2019 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/9cf6e59972e8b5a2ea24493d4fe6b603 to your computer and use it in GitHub Desktop.
Save chelseatroy/9cf6e59972e8b5a2ea24493d4fe6b603 to your computer and use it in GitHub Desktop.
Succeed or Fail
(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