0
我是Haskell的新手,仍然无法完全弄清楚这些类型的问题。我得到的错误以下功能:无法匹配预期类型 - Haskell
computeTriUp :: Point -> Float -> [Point]
computeTriUp center r = [(x + r*cos(pi/2.0), y+r*sin(pi/2.0)), (x+r*cos(5.0*pi/4.0), y+r*sin(5.0*pi/4.0)), (x+r*cos(7.0*pi/4.0), y+r*sin(7.0*pi/4.0))]
where x = fst center
y = snd center
我的错误是:
Couldn't match expected type `Int' with actual type `Float'
In the first argument of `(*)', namely `r'
In the second argument of `(+)', namely `r * cos (pi/2.0)'
In the expression: x + r * cos (pi/2.0)
任何想法? 谢谢!
什么'Point'的定义是什么? – bdonlan
另外,除非你打算稍后替换'Point'的定义,否则你最好在'(x,y)'上进行明确的模式匹配,这样做会使代码更改最小化... – ivanm