Created
November 6, 2017 04:32
-
-
Save rsp/393728702437878bd2d5de4d59bf07da to your computer and use it in GitHub Desktop.
Language Wars - Church numerals - Scheme
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 suc (lambda (a) (lambda (b) (lambda (c) (b ((a b) c)))))) | |
(define add (lambda (a) (lambda (b) (lambda (c) (lambda (d) ((a c) ((b c) d))))))) | |
(define mul (lambda (a) (lambda (b) (lambda (c) (a (b c)))))) | |
(define exp (lambda (a) (lambda (b) (b a)))) | |
(define pre (lambda (a) (lambda (b) (lambda (c) | |
(((a (lambda (d) (lambda (e) (e (d b))))) (lambda (f) c)) (lambda (g) g)))))) | |
(define sub (lambda (a) (lambda (b) ((b pre) a)))) | |
(define ntc (lambda (n) (if (> n 0) | |
(lambda (a) (lambda (b) (a (((ntc (- n 1)) a) b)))) | |
(lambda (a) (lambda (b) b))))) | |
(define ctn (lambda (a) ((a (lambda (x) (+ x 1))) 0))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info: https://github.com/rsp/languagewars-churchnumerals-scheme