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

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -