Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在一次考试中,我发现了这个练习:“编写一个带有文件名的函数(即“text.txt”)并返回一个不带空格的字符列表”
"text.txt" 包含 函数必须返回的"ab e ad c" -> [#"a",#"b",#"e",#"a",#"d",#"c"]
解决这个练习的最简单方法是什么?
我尝试使用库“TextIO”和函数“input1”,但我被卡住了。我不知道如何递归地实现该功能。有人可以帮忙吗?
fun chars filename = let val f = TextIO.openIn filename val s = TextIO.inputAll f in TextIO.closeIn f; List.filter (fn c => c <> #" ") (explode s) end