Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sum3 :: Num a => [a] -> [a] -> [a] -> [a]
- sum3 xs ys zs = sum3Helper [] 0
- where
- maxn = max (max (length xs) (length ys)) (length zs)
- sum3Helper res curn | curn == maxn = reverse res
- | otherwise = sum3Helper ((getElem xs curn 0 + getElem ys curn 0 + getElem zs curn 0) : res) (curn + 1)
- getElem [] n curn = 0
- getElem (x:xs) n curn | curn == n = x
- | otherwise = getElem xs n (curn + 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement