Haskell:将Int转换为字符串 [英] Haskell: Converting Int to String
本文介绍了Haskell:将Int转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道你可以将 String
转换为阅读
的数字:
I know you can convert a String
to an number with read
:
Prelude> read "3" :: Int
3
Prelude> read "3" :: Double
3.0
但是如何抓住 String
表示 Int
值?
推荐答案
读取
的对面是 show
。
Prelude> show 3
"3"
Prelude> read $ show 3 :: Int
3
这篇关于Haskell:将Int转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文