Logo

Programming-Idioms

History of Idiom 202 > diff from v10 to v11

Edit summary for version 11 by senfoel:
New Haskell implementation by user [senfoel]

Version 10

2020-01-05, 23:13:28

Version 11

2020-01-06, 11:42:22

Idiom #202 Sum of squares

Calculate the sum of squares s of data, an array of floating point values.

Idiom #202 Sum of squares

Calculate the sum of squares s of data, an array of floating point values.

Code
sumOfSquares = sum . map (^2)
Comments bubble
Because data is a keyword in Haskell, this is a function for computing the sum of squares.
sumOfSquares :: Num c => [c] -> c