Ethiopian multiplication: Difference between revisions
→{{header|Haskell}}: Replaced with an implementation much like the second, but which I believe to be a more literal translation of the task description.
Underscore (talk | contribs) (→{{header|Haskell}}: Replaced with an implementation much like the second, but which I believe to be a more literal translation of the task description.) |
|||
Line 633:
=={{header|Haskell}}==
<lang haskell>halve,
double = (2 *)
-- 'odd' is included in the Prelude. It could be defined by:
-- odd = (== 1) . (`mod` 2)
ethiopicmult :: Integral a => a -> a -> a
ethiopicmult
(takeWhile (>= 1) $ iterate halve a)
(iterate double b)</lang>
'''Usage example''' from the interpreter
|