
28 May
2009
28 May
'09
1:18 p.m.
On Thu, 2009-05-28 at 13:05 -0400, Thomas Friedrich wrote:
toDigit x = case f x of (0,b) -> [b] (a,b) -> toDigit a ++ [b]
f = \x -> (x `quot` 10, x `mod` 10)
Your function f is almost the same as divMod in Prelude. Also, using a lambda function seems odd; this is simpler:
f x = (x `quot` 10, x `mod` 10)
Anyways, because that's essentially just divMod, toDigit can be simplified thusly:
toDigit x = case x `divMod` 10 of (0, b) -> [b] (a, b) -> toDigit a ++ [b]
Jeff Wheeler