Created
May 12, 2021 20:00
-
-
Save dhilst/528a49a9b9d36f2f0d854e52cdae3a03 to your computer and use it in GitHub Desktop.
Church encoding sketch in python
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
nums = [ | |
(lambda f, x: x), | |
(lambda f, x: f(x)), | |
(lambda f, x: f(f(x))), | |
] | |
result = 0 | |
calls = [] | |
def f(x): | |
global result | |
global calls | |
calls = [f.__name__, calls] | |
result += 1 | |
def plus(m, n, f, x): | |
return m(f, n(f, x)) | |
result = 0 | |
plus(nums[1], nums[1], f, None) | |
print(result) | |
print(calls) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment