Mostly finished SML assignment