compute cos in haskell
fac :: Int -> Int fac n = if (n == 0) then 1 else n * fac (n-1) cos :: Double -> Double cos x = sum [cos| k <- [0..], let cos = (-1) * (x^(2*k) / fromIntegral (fac (2*k))) , abs (cos) > 0.001]
Source: stackoverflow.com