Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sum3 :: Num a => [a] -> [a] -> [a] -> [a]
  2. sum3 xs ys zs = sum3Helper [] 0
  3.   where
  4.     maxn = max (max (length xs) (length ys)) (length zs)
  5.     sum3Helper res curn | curn == maxn = reverse res
  6.                         | otherwise = sum3Helper ((getElem xs curn 0 + getElem ys curn 0 + getElem zs curn 0) : res) (curn + 1)
  7.  
  8.     getElem [] n curn = 0
  9.     getElem (x:xs) n curn | curn == n = x
  10.                           | otherwise = getElem xs n (curn + 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement