Anonymous user
Ethiopian multiplication: Difference between revisions
→{{header|Python}}: Almost the cream of Python...
(→{{header|Python}}: Fully comply with task definition (i hope) :-)) |
(→{{header|Python}}: Almost the cream of Python...) |
||
Line 2,349:
return result</lang>
Using lambdas, a higher-order function, generators, a list comprehension, izip and a generator expression.
<lang python>from itertools import izip
Line 2,357:
even = lambda x: x % 2 == 0
def make_generator(predicate, function):
return generator
halver = make_generator(lambda x: x >= 1, halve)
doubler = make_generator(lambda x: True, double)
▲ x = double(x)
def ethiopian(multiplier, multiplicand):
|