Created
January 21, 2014 17:23
-
-
Save gatlin/8544237 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
(define add (λ (n) | |
(λ (m) | |
(λ (f) | |
(λ (x) | |
((n f) ((m f) x))))))) | |
(define mult (λ (n) | |
(λ (m) | |
(λ (f) | |
(n (m f)))))) |
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
(define (church->number n) | |
((n add1) 0)) |
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
; These two definitions of `one` are equivalent. Why? | |
(define one-manual (λ (f) | |
(λ (x) | |
(f x)))) | |
(define one-computed (succ zero)) |
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
; zero is a function | |
(define zero (λ (f) | |
(λ (x) | |
x))) | |
; succ ("successor") is also a function | |
(define succ (λ (n) | |
(λ (f) | |
(λ (x) | |
(f ((n f) x)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment