Search found 4 matches

by divs1210
Tue Jun 27, 2017 11:43 pm UTC
Forum: Coding
Topic: Multi-line Anonymous Functions in Python
Replies: 32
Views: 38948

Re: Multi-line Anonymous Functions in Python

by divs1210
Tue Jun 27, 2017 8:00 am UTC
Forum: Coding
Topic: Multi-line Anonymous Functions in Python
Replies: 32
Views: 38948

Re: Multi-line Anonymous Functions in Python

What is the point of an anonymous function? Having written a function, why not give it a name and allow the code to be reused? What is the point of an anonymous integer? What is the point of an anonymous boolean? What is the point of an anonymous string? What is the point of an anonymous object? Le...
by divs1210
Sun Jun 25, 2017 9:46 pm UTC
Forum: Coding
Topic: Multi-line Anonymous Functions in Python
Replies: 32
Views: 38948

Re: Multi-line Anonymous Functions in Python

Feel free to join in the shenanigans. :P
by divs1210
Sun Jun 25, 2017 2:00 pm UTC
Forum: Coding
Topic: Multi-line Anonymous Functions in Python
Replies: 32
Views: 38948

Re: Multi-line Anonymous Functions in Python

First define the Y combinator: def Y(g): exp = lambda f: g(lambda arg: f(f)(arg)) return (exp)(exp) This will allow you to have 'named' (recursive) lambdas: Y(lambda fact: lambda n: 1 if n < 2 else n * fact(n - 1))(5) # => 120 So your code becomes: Y(lambda f: lambda a: 1 if a == 1 else (f(a/2) if a...

Go to advanced search