Hi i won't to make a function in standard ML that takes as input integers separated by spaces in many lines and returns a list of them one by one. For example, for the input file
3 4 5 6 7 8 4
4 5 6 2 3
6 4 3 2
2 3 5 6 7
to return a list [3,4,5,6,7,8,4,4,5,6,2,3,6,4,3,2,2,3,5,6,7]
.
I had tried to figure it out myself but i couldn't because i don't have good knowledge of ML's IO functions. I would appreciate your help. Thank you
I agree with Sebastian. here is an example reading integer
fun int_from_stream stream =
Option.valOf (TextIO.scanStream (Int.scan StringCvt.DEC) stream)
val fstream = TextIO.openIn file
val N = int_from_stream fstream