pmb: (kitty behind printer)
[personal profile] pmb
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?
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

pmb: (Default)
pmb

October 2009

S M T W T F S
    1 23
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 29th, 2026 11:49 pm
Powered by Dreamwidth Studios