我的这个功能有问题,应该划分列表的所有元素。
[x1,x2,x3,x4,x5,x6] = (((((x1/x2)/x3)/x4)/x5)/x6)
到目前为止我的代码是:
division :: [Double] -> Double
divis :: [Double] -> Double
divis [] = 0
divis [x] = x
divis (x1:xs) = ????
我怎么能解决这个问题?
答案 0 :(得分:0)
所以我找到了2个解决方案。致Alec和Mark Seemann
divis :: [Double] -> Double
divis [x] = x
divis (x1 : xs) = x1 / mul xs
和
div2 :: [Double] -> Double
div2 (x1:xs) = foldl (/) x1