haskell - Square a list of numbers and divide it by the mean of the list -
i need square list of numbers , divide mean of list. far have got:
square :: float -> float square x = x * x s2 :: [float] -> float s2 xs = map square (map (\c -> c - mean) xs)
any apreciated.
s2 :: [float] -> float s2 xs = sum $ map ((/mean).(^2)) xs mean= sum xs / fromintegral (length xs)
test:
λ: s2 [1.0, 2.0, 3.0] 7.0
Comments
Post a Comment