(* This is the transcript of lecture #2, for a few minutes, but in fact most of that lecture was on the blackboard. *) $ sml.bat Standard ML of New Jersey v110.73 [built: Mon May 16 06:14:15 2011] - use "util.sml"; [opening util.sml] [autoloading] [library $smlnj/cm/cm.cm is stable] [library $smlnj/internal/cm-sig-lib.cm is stable] [library $/pgraph.cm is stable] [library $smlnj/internal/srcpath-lib.cm is stable] [library $SMLNJ-BASIS/basis.cm is stable] [library $smlnj/compiler/current.cm is stable] [library $smlnj/compiler/x86.cm is stable] [library $smlnj/viscomp/core.cm is stable] [library $smlnj/viscomp/basics.cm is stable] [library $smlnj/viscomp/elabdata.cm is stable] [library $smlnj/viscomp/elaborate.cm is stable] [library $smlnj/viscomp/debugprof.cm is stable] [library $SMLNJ-LIB/Util/smlnj-lib.cm is stable] [library $smlnj/MLRISC/Control.cm is stable] [library $SMLNJ-MLRISC/Control.cm is stable] [library $controls-lib.cm(=$SMLNJ-LIB/Controls)/controls-lib.cm is stable] [library $smlnj/smlnj-lib/controls-lib.cm is stable] [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 - val d : bool = true; val d = true : bool - val a = 9; val a = 9 : int - 7+4; val it = 11 : int - fun fact(n) = if n=0 then 1 else n * fact(n-1); val fact = fn : int -> int - fact (6); val it = 720 : int - fact (fact(6)); uncaught exception Overflow [overflow] raised at: - fact 6; val it = 720 : int - (fact) 6; val it = 720 : int - fact fact 6; stdIn:9.1-9.12 Error: operator and operand don't agree [tycon mismatch] operator domain: int operand: int -> int in expression: fact fact - fact (fact 6); uncaught exception Overflow [overflow] raised at: - val x = ref 0; val x = ref 0 : int ref - x := 7; val it = () : unit - val it = x := 7; val it = () : unit - !x; val it = 7 : int - x := !x + 7; - !x = ; val it = 14 : int - fun iterfact (n) = = let val x = ref 1 = val y = ref 1 = in while !y <= n do (x := !x * !y; y := !y + 1); = !x = end; val iterfact = fn : int -> int - iterfact 6; val it = 720 : int - fun tailfact(n,x) = if n=0 then x else tailfact (n-1,n*x); val tailfact = fn : int * int -> int - tailfact(6,1); val it = 720 : int - 7.0 * 5; stdIn:26.1-26.8 Error: operator and operand don't agree [literal] operator domain: real * real operand: real * int in expression: 7.0 * 5 - 7.0 * 5.0; val it = 35.0 : real - 7*5; val it = 35 : int - 7.0 * real 5; val it = 35.0 : real - CM.make "sources.cm"; [scanning sources.cm] [loading (sources.cm):slp.sml] [loading (sources.cm):maxarg.sml] [loading (sources.cm):interp.sml] [loading (sources.cm):testprog.sml] [loading (sources.cm):test.sml] [New bindings added.] val it = true : bool - SLP.Plus; val it = Plus : SLP.binop -