Created
October 17, 2019 01:51
-
-
Save artisonian/829c100826c46f7118324c4d2eedf926 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
#lang racket/base | |
(require racket/list | |
racket/match) | |
; The call-by-value lambda calculus: | |
(define (eval-expr expr env) | |
(match expr | |
[(? symbol?) | |
(env expr)] | |
[`(lambda (,x) ,body) | |
(λ (arg) | |
(eval-expr body (λ (y) | |
(if (eq? x y) | |
arg | |
(env y)))))] | |
[`(,rator ,rand) | |
((eval-expr rator env) | |
(eval-expr rand env))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment