将字符串转换为标准 ML 中的列表
可能的重复:
在 ML(SMLNJ) 中打开文件
我有一个字符串值,其值如下:
"[(1,2,3),(2,3),(6,8)]" -> string
但我想要像这样 int 类型的这些值:
[(1,2,3),(2,3),(6,8)] -> (int list) list
我应该做什么?有什么函数可以帮助我吗?或者我必须自己做?
Possible Duplicate:
Open file in ML(SMLNJ)
I have a string value which has value like this:
"[(1,2,3),(2,3),(6,8)]" -> string
but I want to have these values in int type like this:
[(1,2,3),(2,3),(6,8)] -> (int list) list
what should I do?is there any function which can help me? or I have to do it myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题非常适合解析组合器,你可以从我的朋友格雷格那里窃取哈佛大学的莫里塞特。
如果您想了解基本思想,请阅读 Graham Hutton 的论文 Higher - 用于解析的函数的顺序。如果您想了解如何在标准 ML 中实现 I/O,请参阅
标准基础库中的 TextIO
模块。如果您希望有人为您编写代码,您可能访问了错误的网站。This problem is perfectly suited to parsing combinators, which you can steal from my friend Greg Morrisett at Harvard.
If you want to understand the underlying ideas, read Graham Hutton's paper Higher-Order Functions for Parsing. If you want to know how to implement I/O in Standard ML, consult the
TextIO
module in the Standard Basis Library. If you want someone to write the code for you, you may have reached the wrong web site.您可以使用
String
模块中的stringint
。例如,请参见 http://wwwcgi.rdg.ac.uk:8081/cgi-bin/cgiwrap/wsi14/poplog/ml/help/string#Character%20Transformation%20Functions
You can use
stringint
from theString
module.See for example http://wwwcgi.rdg.ac.uk:8081/cgi-bin/cgiwrap/wsi14/poplog/ml/help/string#Character%20Transformation%20Functions