Ethiopian multiplication: Difference between revisions

→‎{{header|Python}}: Final (I hope) cleanup. Sorry for the many edits :-)
(→‎{{header|Python}}: Cleanup, more in line with other examples)
(→‎{{header|Python}}: Final (I hope) cleanup. Sorry for the many edits :-))
Line 2,349:
return result</lang>
 
Using generators, izipa list comprehension, izip and a generator expression.
 
<lang python>from itertools import izip
Line 2,367:
 
def ethiopian(multiplier, multiplicand):
table = list([(p, q) for p, q in
izip(halver(multiplier), doubler(multiplicand)))]
returnresult = sum(q for p, q in table if not even(p))
return result</lang>
 
=={{header|R}}==
Anonymous user