Ich bin zu SML sehr neu und ich versuche, einige Elemente zu einer Liste Artikel SML zur Liste hinzufügen
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;
Ich erhalte eine leere Ausgabedatei, wenn ich den Code ausführen und ich
hinzufügen m Mühe, herauszufinden, warum, aber ich weiß, dass die Hilfsfunktion, die richtigen Werte aus der „Handlung“ -Funktion wird immer, weil ich es getestet, indem das drucken mit (Aktion (...))Dank