Warning - dangerous nerdery ahead!
Mar. 31st, 2005 11:38 pm
def voodoo(f):
def A(x):
def B(y):
return x(x)(y)
return f(B)
return A(A)
def hypothetical_fact(factorial):
def f(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
return f
fact = voodoo(hypothetical_fact)
print fact(30)
The Z combinator is messed up. Anybody want to explain the above code to me?
Re: I'll give it a shot...
Date: 2005-04-01 05:12 pm (UTC)