summaryrefslogtreecommitdiff
path: root/plt/lambda-calculus.md
diff options
context:
space:
mode:
authorJJ2024-05-20 03:04:59 +0000
committerJJ2024-05-20 03:04:59 +0000
commited8c2d6b56655f1a362f7683b9da3ac521920a42 (patch)
tree08d1936993e2a9b9d07433b3ea8a4a05487634d5 /plt/lambda-calculus.md
parent8f7194de7767f8cede241682a368d01bcda66abc (diff)
meow
Diffstat (limited to 'plt/lambda-calculus.md')
-rw-r--r--plt/lambda-calculus.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/plt/lambda-calculus.md b/plt/lambda-calculus.md
index b666ef6..7d15dbf 100644
--- a/plt/lambda-calculus.md
+++ b/plt/lambda-calculus.md
@@ -4,3 +4,23 @@ title: computation/lambda calculus
---
# the lambda calculus
+
+the lambda calculus is a simple expression of computation.
+
+```racket
+;; A full implementation of the untyped lambda calculus in Racket.
+(define (interpret expr [ctx #hash()])
+ (match expr
+ [val #:when (value? val) val]
+ [val #:when (symbol? val)
+ (if (dict-has-key? ctx val)
+ (interpret (dict-ref ctx val) ctx) val)]
+ [`(λ ,id ,body) `(λ ,id ,body)]
+ [`(,body ,arg)
+ (match (interpret body ctx)
+ [`(λ ,id ,body) (interpret body (dict-set ctx id (interpret arg ctx)))]
+ [expr `(,(interpret expr ctx) ,(interpret arg ctx))])]
+ [expr (error (format "invalid expression ~a" expr))]))
+```
+
+in computer science, the lambda calculus is often used as a base for languages and types systems for its simplicity and extended with syntax and types of various fashions. in linguistics, the lambda calculus is used for its compact notation of functions and is often extended with quantifiers and abstract functions. in mathematics, the lambda calculus is studied in its own right.