gauravssnl / skulpt

Automatically exported from code.google.com/p/skulpt
Other
0 stars 0 forks source link

Applicative order Y combinator fails with TypeError #101

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Code you're trying to run:

Y = lambda f: (lambda x: x(x))(lambda x: f(lambda *args: x(x)(*args)))
almost_fac = lambda f: \
    lambda n: \
    1 if n==0 else n * f(n-1)

factorial = Y(almost_fac)
print factorial(6)

What does "real" Python output?

720

What does Skulpt output?

TypeError: Cannot read property 'tp$call' of undefined

Please provide any additional information.

the recursive Y function instead works fine :D

Y = lambda f: f(lambda x: Y(f)(x))

Y(almost_fac)(7)

correctly returns 5040

Original issue reported on code.google.com by berdario on 26 Oct 2011 at 11:38