Created
April 11, 2015 21:00
-
-
Save YuukiARIA/e6b4d501d6be95029950 to your computer and use it in GitHub Desktop.
work in progress
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
module Church | |
Z = -> (s) { -> (z) { z } } | |
SUCC = -> (x) { -> (s) { -> (z) { s[x[s][z]] } } } | |
ADD = -> (x) { -> (y) { -> (s) { -> (z) { y[s][x[s][z]] } } } } | |
def value(x, succ: -> (n) { n + 1 }, unit: 0) | |
x[succ][unit] | |
end | |
end | |
include Church | |
p value(SUCC[Z]) | |
# ==> 1 | |
p value(ADD[SUCC[SUCC[Z]]][SUCC[SUCC[SUCC[Z]]]]) | |
# ==> 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment