📜  在 haskell 中计算 cos - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:02.849000             🧑  作者: Mango

代码示例1
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]