mhofmann@trento:~/Documents$ sml Standard ML of New Jersey v110.69 [built: Mon Jun 8 14:15:08 2009] - type studi = {name:string, alter:int}; type studi = {alter:int, name:string} - type prof = {name:string, alter:int, gehalt:real}; type prof = {alter:int, gehalt:real, name:string} - val x = {titel="tschick", ISBN="378"}; val x = {ISBN="378",titel="tschick"} : {ISBN:string, titel:string} - {titel="A",ISBN="B"} = {ISBN="B", titel="A"}; val it = true : bool - val x = [1,2,3,4,5,6]; val x = [1,2,3,4,5,6] : int list - x @ x; val it = [1,2,3,4,5,6,1,2,3,4,5,6] : int list - [[1]]; val it = [[1]] : int list list - val x = [[1]]; val x = [[1]] : int list list - x @ x; val it = [[1],[1]] : int list list - fun mktestlist n = if n=0 then [0] else n :: mktestlist (n-1) = ; val mktestlist = fn : int -> int list - mktestlist 1; val it = [1,0] : int list - 1 :: [0]; val it = [1,0] : int list - 8 :: [4,5,6]; val it = [8,4,5,6] : int list - [5+6,7]; val it = [11,7] : int list - [5+6,7] = [11,3+4]; val it = true : bool - [11,7] = [7,11]; val it = false : bool - fun f(a:int, l) = a::l; val f = fn : int * int list -> int list - f(3,[4,5]); val it = [3,4,5] : int list - [1] :: [2]; stdIn:47.1-47.11 Error: operator and operand don't agree [literal] operator domain: int list * int list list operand: int list * int list in expression: (1 :: nil) :: 2 :: nil - [1] :: [[2]]; val it = [[1],[2]] : int list list - mktestlist 1; val it = [1,0] : int list - mktestlist 10; val it = [10,9,8,7,6,5,4,3,2,1,0] : int list - mktestlist 100000; val it = [100000,99999,99998,99997,99996,99995,99994,99993,99992,99991,99990,99989, ...] : int list - fun f(x:int, y) = x::y; val f = fn : int * int list -> int list - fun f(x, y) = x::y; val f = fn : 'a * 'a list -> 'a list - f(true,[true,false,true]); val it = [true,true,false,true] : bool list - f(8,[9,10,22]); val it = [8,9,10,22] : int list - f(true,[9,10,22]); stdIn:55.1-55.18 Error: operator and operand don't agree [literal] operator domain: bool * bool list operand: bool * int list in expression: f (true,9 :: 10 :: :: ) - fun g(x,y) = x; val g = fn : 'a * 'b -> 'a - fun h(x,y) = (y,x); val h = fn : 'a * 'b -> 'b * 'a - fun laenge([]) = 0 = | laenge(x::r) = 1 + laenge(r); val laenge = fn : 'a list -> int - laenge [1,2,3]; val it = 3 : int - fun laenge([]) = 0 = | laenge(x::r) = laenge(x)+1; stdIn:61.18-61.29 Error: operator and operand don't agree [circularity] operator domain: 'Z list operand: 'Z in expression: laenge x - fun head (kopf::rumpf) = kopf; stdIn:24.1-56.14 Warning: match nonexhaustive kopf :: rumpf => ... val head = fn : 'a list -> 'a - head([1,2,3,4,5]); val it = 1 : int - head([0,22,3,4,5]); val it = 0 : int - head([]); stdIn:64.1-64.9 Warning: type vars not generalized because of value restriction are instantiated to dummy types (X1,X2,...) uncaught exception Match [nonexhaustive match failure] raised at: stdIn:56.14 - fun head([]) = 0 | head(kopf::rumpf) = kopf; val head = fn : int list -> int - fun head (kopf::rumpf) = kopf; stdIn:65.5-65.30 Warning: match nonexhaustive kopf :: rumpf => ... val head = fn : 'a list -> 'a - fun tail(kopf::rumpf) = rumpf; stdIn:66.5-66.30 Warning: match nonexhaustive kopf :: rumpf => ... val tail = fn : 'a list -> 'a list - tail([2,3,4,5,6]); val it = [3,4,5,6] : int list - fun laenge(l) = if l=[] then 0 else 1+laenge(tail(l)); stdIn:68.21 Warning: calling polyEqual val laenge = fn : ''a list -> int - laenge ([3,4,5,6,7]); val it = 5 : int - fun is_empty([]) = true = | is_empty(a::l) = false; val is_empty = fn : 'a list -> bool - is_empty([]); val it = true : bool - is_empty([1,2,3]); val it = false : bool - fun is_empty([]) = true = | is_empty(_::_) = false; val is_empty = fn : 'a list -> bool - fun is_in(x,[]) = false = | is_in(x,k::r) = x=k orelse is_in(x,r); stdIn:77.20 Warning: calling polyEqual val is_in = fn : ''a * ''a list -> bool - is_in(4,[1,4,5]); val it = true : bool - fun reverse([]) = [] = | | reverse ;;reverse ;; C-c C-c Interrupt - fun reverse ([]) = [] = |reverse (k::r) = reverse(r) @ [k]; val reverse = fn : 'a list -> 'a list - reverse([1,2,3,4]); val it = [4,3,2,1] : int list - mktestlist 100; val it = [100,99,98,97,96,95,94,93,92,91,90,89,...] : int list - reverse(mktestlist(100)); val it = [0,1,2,3,4,5,6,7,8,9,10,11,...] : int list - reverse(mktestlist(1000)); val it = [0,1,2,3,4,5,6,7,8,9,10,11,...] : int list - reverse(mktestlist(10000)); val it = [0,1,2,3,4,5,6,7,8,9,10,11,...] : int list - reverse(mktestlist(100000)); val it = [0,1,2,3,4,5,6,7,8,9,10,11,...] : int list -