1
經典問題,但在Haskell這次。我嘗試這樣做的C方式,但我不斷收到此錯誤Haskell中整數的位數
Variable not in scope: numDigits :: Integer -> t
下面是我寫的
numDigits :: Integer -> Integer
numDigits n = toInteger (round (logBase 10 (fromIntegral n)) + 1)
代碼難道我錯了嗎?或者日誌
什麼'toInteger'的簽名?不記得了。另外,爲什麼不把它定義爲'長度。 show'? – Carcigenicate
toInteger,因爲日誌庫10返回一個雙我想? –
你是在REPL還是源文件中執行此操作? – Carcigenicate