Skip to content

Commit

Permalink
:lambda: Add K example, KI, and a few equivalences.
Browse files Browse the repository at this point in the history
  • Loading branch information
iglesias committed May 28, 2024
1 parent ac0116a commit a9f2a6a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions custom/lambda_calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,15 @@ def M(f):
def K(a, b=None):
return (lambda _: a) if b is None else a

Konstant = K('onstant')
# print(Konstant('what?'))

assert K(I)('x')('y') == 'y'

def KI(a, b=None):
return (lambda _: b) if a is None else b

assert(K(M,KI) == K(M,K(I)) == M)
assert(KI(M,K) == K(I)(M)(K) == K)
assert(KI(K,M) == K(I)(K)(M) == M)

0 comments on commit a9f2a6a

Please sign in to comment.