Re: [Haskell-cafe] recursion problem part 2

6 Feb
2015
6 Feb
'15
10:40 a.m.
Dmitry Olshansky schreef op 6-2-2015 om 16:25:
toDigits :: Integer -> [Integer] toDigits n | n < 0 = [] | n < 10 = [n] | otherwise = toDigits (n `div` 10) ++ [n `mod` 10]
Thanks that worked, I have now to figure out why I see [0] on 0 and no zero when it reaches it end-point. isDigits 0 n< 10 so [0] IsDigits 1 n < 0 not true n < 10 not true. toDigits 1 ++ [0] toDigits 1 + [0] n< 0 not true n < 10 true so [1] ++ [0] [1] ++ [0] is [1.0] where the output is [1] So somehow I do not understand fully how this works . Roelof
3757
Age (days ago)
3757
Last active (days ago)
0 comments
1 participants
participants (1)
-
Roelof Wobben