3 ms·
I'm not sure your solution computes what you want. A[2] = B[2-1] + C[2+1] A[2] = B[1] + C[3] A[2] = 2 + 9 A[2] = 11 Your solution gives 12 for A[2]. f
by tkahn6 15y ago
I'm not sure your solution computes what you want.
A[2] = B[2-1] + C[2+1]
A[2] = B[1] + C[3]
A[2] = 2 + 9
A[2] = 11
Your solution gives 12 for A[2].
f xs ys = zipWith (+) (0:xs) $ tail $ ys ++ [0]
f [1..5] [6..10] == [7,9,11,13,4]
I assume you want B[-1] and C[5] to yield 0 in this case.