(* Mandatory exercise 1, INF3110/4110, 2007 *) (* datatype declarations *) (* you might need to declare other datatypes in addition to the ones sketched here *) (* your datatype declaration for expressions *) datatype exp = (* your datatype declaration for statements *) datatype stmt = (* the datatype for program *) type prog = stmt list ; (* program state *) type state = fun getVal(x:var, s:state):int = fun putVal(x:var, n:int, s:state):state = fun stateToStr(s:state):string = (* your initial state with i=j=k=0 *) val init = (* your ML representation of the sample program *) val sampleprog = (* evaluation of an expression in a state *) fun evalExp(e:exp,s:state):int = (* evaluation of a statement in a state *) fun eval(st:stmt, s:state):state = (* the interpret function *) fun interpret(p:prog,s:state):state = (* code to test your implementation *) (print "(*** Program start ***)\n"; print ("Initial state: \t"^(stateToStr(init))); print ("Final state: \t"^(stateToStr(interpret(sampleprog,init)))); print "(*** Program end ***)\n");