tags:

views:

173

answers:

2

I have this SML/NJ code that reads a single line from a text file and then it will return a list for me, but I am having trouble making it do the same thing to every single line and stop when there are no more lines. Can anyone please help me by giving me a looping sample here?

fun readlist(infile : string) =
let val ins = TextIO.openIn infile

    val list = []
     fun listing() = [TextIO.inputLine ins]::list;

in listing()
end
A: 

How about something like this:

fun readlist (infile : string) = let
  val ins = TextIO.openIn infile
  fun loop ins =
   case TextIO.inputLine ins of
      SOME line => line :: loop ins
    | NONE      => []
in
  loop ins before TextIO.closeIn ins
end
newacct
A: 

I want to do same but it returns only 70 character per line ? what should i do ?

student