0
我很新的SML和我想要一些項目添加到列表中添加項目列出SML
fun foo(inFile : string, outFile : string) = let
val file = TextIO.openIn inFile
val outStream = TextIO.openOut outFile
val contents = TextIO.inputAll file
val lines = String.tokens (fn c => c = #"\n") contents
val lines' = List.map splitFirstSpace lines
fun helper1(lis : string list) =
case lis of
[] => (TextIO.closeIn file; TextIO.closeOut outStream)
| c::lis => (TextIO.output(outStream, c);
helper1(lis))
fun helper(lis : (string * string) list, stack : string list) =
case lis of
[] => stack
| c::lis => (act(#1 c, #2 c)::stack;
helper(lis, stack))
val x = helper(lines', [])
in
helper1(x)
end;
我得到一個空的輸出文件,每當我跑的代碼和我」有問題搞清楚爲什麼,但我知道,輔助功能從「行爲」的功能得到適當的值,因爲我用的打印(動作(...))
感謝