在 SML/NJ 中循环文本文件的行
我有这个 SML/NJ 代码,它从文本文件中读取一行,然后它会为我返回一个列表,但我很难让它对每一行执行相同的操作,并在没有更多行时停止。 任何人都可以在这里给我一个循环样本来帮助我吗?
fun readlist(infile : string) =
let val ins = TextIO.openIn infile
val list = []
fun listing() = [TextIO.inputLine ins]::list;
in listing()
end
I have this SML/NJ code that reads a single line from a text file and then it will return a list for me, but I am having trouble making it do the same thing to every single line and stop when there are no more lines. Can anyone please help me by giving me a looping sample here?
fun readlist(infile : string) =
let val ins = TextIO.openIn infile
val list = []
fun listing() = [TextIO.inputLine ins]::list;
in listing()
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的事情怎么样:
How about something like this: