Created
November 2, 2022 23:15
-
-
Save EduardoRFS/36c74638b414f69c8dd23415ca02a988 to your computer and use it in GitHub Desktop.
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
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