map f [a,b,c] = [fa, fb, fc]
because map f (x:xs) = fx:map f xs - apply f to each element of the list.
So,
map (negate.sum.tail) [[1..5],[3..6],[1..7]] = [(negate.sum.tail) [1..5], (negate.sum.tail) [3..6], (negate.sum.tail) [1..7]]
now
(negate . sum . tail) [1..5] = negate (sum (tail [1,2,3,4,5])) = negate (sum [2,3,4,5]) = negate 14 = -14
because (fg) x = f (gx) and . are correct associative, therefore (negate.sum.tail) xs = (negate.(sum.tail)) xs , which, in turn, negate ((sum.tail) xs) = negate (sum (tail xs)) .
tail provides everything except the first element of the list: tail (x:xs) = xs , for example tail "Hello" = "ello" sum adds them, as you expect, and negate x = -x .
Others work similarly, giving minus the sum of the tail of each list.
source share