[Shootout-list] MLton - Sum of a Column of Numbers
Raymond Racine
rracine@adelphia.net
Sat, 25 Sep 2004 13:52:16 -0400
(* MLton for sumcol *)
fun sumlines sum =
case TextIO.inputLine TextIO.stdIn of
SOME str => sumlines (sum + (Option.valOf (Int.fromString str)))
| NONE => (print (Int.toString sum); print "\n")
val _ = sumlines 0
----------------------------------------------------------------------------
I was looking at the MLton SML, sumcol.sml failed test and noticed that
it was a bit parenthetical along with an extraneous eof check in the if
statement. (Probably because of the change to the SML basis to
TextIO.inputLine: TextIO.instream -> string option)
The above is more concise.
Ray