[MLton] commitlog

Stephen Weeks MLton@mlton.org
Wed, 22 Oct 2003 09:47:40 -0700


> Would it be possible to emit the commitlog in reverse chronological order
> (newest items at the top)?

I added a nightly cron job to reverse the commitlog and put it in the
web dir.  Hopefully that's close enough.  Here's
reverse-commitlog.sml, the script that does the reverse.

----------------------------------------------------------------------
structure List =
   struct
      fun foreach (l, f) = List.app f l
   end

fun line () = TextIO.inputLine TextIO.stdIn
   
fun loop (m, ms) =
   case line () of
      NONE => List.foreach (m :: ms, fn m => List.foreach (rev m, print))
    | SOME l =>
	 if Char.isSpace (String.sub (l, 0))
	    then loop (l :: m, ms)
	 else loop ([l], m :: ms)

val _ = loop ([], [])
----------------------------------------------------------------------