Skip to content

Instantly share code, notes, and snippets.

@dhilst
Created May 12, 2021 20:00
Show Gist options
  • Save dhilst/528a49a9b9d36f2f0d854e52cdae3a03 to your computer and use it in GitHub Desktop.
Save dhilst/528a49a9b9d36f2f0d854e52cdae3a03 to your computer and use it in GitHub Desktop.
Church encoding sketch in python
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