selectMenu :: Int->IO()
selectMenu num
|(num==2)=convertBinToDecimal
convertBinToDecimal:: IO()
convertBinToDecimal= do
putStrLn("\n\tConvert Binary To Decimal\n")
putStrLn("----------------------------------------------------------\n")
putStrLn("Enter 5 binary numbers [,,] : ")
input<-getLine
let n=(read input)::Int
--putStrLn (show n)
let result = convertionTO binaryToDec n
putStrLn(show result)
此代碼似乎很好,但出現錯誤。將二進制轉換爲十進制
解決此錯誤的任何解決方案? 謝謝
你寫'putStrLn(「Foo」)'的方式有點奇怪。把'f'的函數'f'寫成'f x'更爲常見,所以在你的情況下'putStrLn「Foo」'更自然。 – gspr 2012-02-07 11:20:34
謝謝。我會改變這個......再次感謝你 – JJ23 2012-02-07 11:33:26