$ sml.bat Standard ML of New Jersey v110.73 [built: Mon May 16 06:14:15 2011] - val x = 7+6; val x = 13 : int - val d = 12; val d = 12 : int - use "01.sml"; [opening 01.sml] val a = 5 : int val b = true : bool val c = 7 : int val d = fn : int -> int datatype money = BILL of int | CHECK of string * real | COIN of int val value = fn : money -> real val it = () : unit - val b = BILL(7); val b = BILL 7 : money - val b = BILL 7; val b = BILL 7 : money - val b = 6; val b = 6 : int - fun fact(n) = if n=0 then 1 else n * fact(n-1); val fact = fn : int -> int - fact 5; val it = 120 : int - val it = fact 5; val it = 120 : int - val b = BILL 7; val b = BILL 7 : money - val nickel = COIN 5; val nickel = COIN 5 : money - val tenspot = BILL 10; val tenspot = BILL 10 : money - value nickel; val it = 0.05 : real - value tenspot; val it = 10.0 : real - value (CHECK ("Joe",10.50)); val it = 8.4 : real - use "slp.sml"; [opening slp.sml] structure SLP : sig type id = string datatype binop = Div | Minus | Plus | Times datatype stm = AssignStm of id * exp | CompoundStm of stm * stm | PrintStm of exp list datatype exp = EseqExp of stm * exp | IdExp of id | NumExp of int | OpExp of exp * binop * exp end val it = () : unit - use "idents.sml"; [opening idents.sml] val stm_ids = fn : SLP.stm -> SLP.id list val elist_ids = fn : SLP.exp list -> SLP.id list val exp_ids = fn : SLP.exp -> SLP.id list val it = () : unit - use "testprog.sml"; [opening testprog.sml] structure TestProg : sig structure S : val prog : SLP.stm end val it = () : unit - stm_ids TestProg.prog; val it = ["a","b","a","a","a","b"] : SLP.id list - datatype intlist = CONS of int * intlist | NIL; datatype intlist = CONS of int * intlist | NIL - CONS(3,CONS(1,CONS(4,NIL))); val it = CONS (3,CONS (1,CONS #)) : intlist - use "util.sml"; [opening util.sml] [autoloading done] structure U : sig val printdepth : int -> unit val cd : string -> unit val pwd : unit -> string val exit : unit -> 'a val make : unit -> bool end val it = () : unit - printdepth 50; stdIn:32.1-32.11 Error: unbound variable or constructor: printdepth - U.printdepth 50; val it = () : unit - CONS(3,CONS(1,CONS(4,NIL))); val it = CONS (3,CONS (1,CONS (4,NIL))) : intlist - (* datatype 'a list = nil | :: of 'a * 'a list; *) - 5::nil; val it = [5] : int list - [5,6,7,8]; val it = [5,6,7,8] : int list - 5::(6::(7::8::nil)); val it = [5,6,7,8] : int list - 5::6::7::8::nil; val it = [5,6,7,8] : int list - nil; val it = [] : 'a list - val a = nil : int list; val a = [] : int list - case a of nil => 5 | x::y => x+6; val it = 5 : int - fun sum(x: int list) = case x of nil => 0 | a::ar => a + sum ar ; val sum = fn : int list -> int - sum [5,6,7,8]; val it = 26 : int - fun f(x: int list) = case x of nil => nil | a::ar => (a+1):: f ar; val f = fn : int list -> int list - f [5,6,7,8]; val it = [6,7,8,9] : int list -