Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sumTwo :: [Int] -> [Int] -> [Int]
sumTwo x y = doit x y [] 0
where
doit [] [] sum 0 = reverse sum
doit [] [] sum carry = doit [] [] (carry : sum) 0
doit (x : xs) (y : ys) sum carry =
let tot = x + y + carry
(n, nc) =
if tot > 9
then (tot - 10, 1)
else (tot, 0)
in doit xs ys (n : sum) nc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.