I'm playing around with some Input/Output functions in SML, and I'm wondering if it's possible to copy specific content from one file to another, instead of copying the whole thing?
Say that I have a function in one of the text files that returns a list of integers, and I just want to copy this result list into the empty output file. And if this is possible, how can I apply my copyFile function to copy the list automaticly to the output file?
Here's the function I'm using for copy the whole text from one file to another:
fun copyFile(infile: string, outfile: string) =
let
val In = TextIO.openIn infile
val Out = TextIO.openOut outfile
fun helper(copt: char option) =
case copt of
NONE => (TextIO.closeIn In; TextIO.closeOut Out)
| SOME(c) => (TextIO.output1(Out,c); helper(TextIO.input1 In))
in
helper(TextIO.input1 In)
end