我試圖定義:轉換浮動到整數
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