将字符串转换为标准 ML 中的列表

发布于 2024-08-19 20:36:54 字数 388 浏览 6 评论 0原文

可能的重复:
在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

高跟鞋的旋律 2024-08-26 20:36:54

这个问题非常适合解析组合器,你可以从我的朋友格雷格那里窃取哈佛大学的莫里塞特

如果您想了解基本思想,请阅读 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文