Averages/Pythagorean means: Difference between revisions
→Haskell - Three applicatively defined functions: Simplifed the three functions with a liftM2 (locally defined, rather than imported)
(→{{header|Haskell}}: Added an alternative, defining the functions applicatively, and testing with (and zipWith (>=))) |
(→Haskell - Three applicatively defined functions: Simplifed the three functions with a liftM2 (locally defined, rather than imported)) |
||
Line 1,242:
-- ARITHMETIC, GEOMETRIC AND HARMONIC MEANS -----------------------
arithmetic, geometric, harmonic :: [Double] -> Double
arithmetic =
geometric =
harmonic =
-- GENERIC --------------------------------------------------------
liftM2 f g h = pure f <*> g <*> h
-- TEST -----------------------------------------------------------
|