Skip to content

Instantly share code, notes, and snippets.

@kmicinski
Created February 13, 2020 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmicinski/1a954ef4af045e5c7412f7fe2c0c1122 to your computer and use it in GitHub Desktop.
Save kmicinski/1a954ef4af045e5c7412f7fe2c0c1122 to your computer and use it in GitHub Desktop.
;; lambda calculus notes
#lang racket
;; Lambda calculus terms in Racket:
;; 'x
;; '(lambda (x) x)
;; '((lambda (x) x) x), '((lambda (x) x) y)
;; '((lambda (x) x) (lambda (y) y))
(define (lambda-term? e)
(match e
[(? symbol?) #t]
[`(lambda (,(? symbol? x)) ,(? lambda-term? e-body)) #t]
[`(,(? lambda-term? e0) ,(? lambda-term? e1)) #t]
[_ (error (format "The S-expression ~a is not a lambda term" (pretty-format e)))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment