Skip to content

Instantly share code, notes, and snippets.

@artisonian
Created October 17, 2019 01:51
Show Gist options
  • Save artisonian/829c100826c46f7118324c4d2eedf926 to your computer and use it in GitHub Desktop.
Save artisonian/829c100826c46f7118324c4d2eedf926 to your computer and use it in GitHub Desktop.
#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