我试图定义:转换浮动到整数
square :: Integer -> Integer
square = round . (** 2)
和我得到:
<interactive>:9:9: error:
• No instance for (RealFrac Integer) arising from a use of ‘round’
• In the first argument of ‘(.)’, namely ‘round’
In the expression: round . (** 2)
In an equation for ‘square’: square = round . (** 2)
<interactive>:9:18: error:
• No instance for (Floating Integer)
arising from an operator section
• In the second argument of ‘(.)’, namely ‘(** 2)’
In the expression: round . (** 2)
In an equation for ‘square’: square = round . (** 2)
我还在这个语言新,我似乎是不能转换的实例浮动到整数。有谁知道我该怎么做?
这是卢基的答案是否可以用于评论亚历克的答案,这是值得商榷的,但这肯定可能是对卢奎答案的评论。 – chepner