-
-
Save mikaelsouza/518da028ecc72484597a910bad70ee9a 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
type term = Var of string | Lam of string * term | App of term * term | |
type value = Closure of ((string * value) list * string * term) | |
let rec eval env term = | |
match term with | |
| Var var -> List.assoc var env | |
| Lam (param, body) -> Closure (env, param, body) | |
| App (lambda, argument) -> ( | |
let lambda = eval env lambda in | |
let argument = eval env argument in | |
match lambda with | |
| Closure (env, param, body) -> | |
let env = (param, argument) :: env in | |
eval env body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment