trutta[0][cs171] > sml Standard ML of New Jersey, Version 109.27, April 20, 1997 - - fun mult(n:int, m:int) = = if n=1 then = m = else = m + mult(n-1,m); val mult = fn : int * int -> int - - mult(2,3); val it = 6 : int - - mult(7,5); val it = 35 : int - - fun Sum1toN (N:int) = = if N=1 then = 1 = else = N + Sum1toN (N-1); val Sum1toN = fn : int -> int - - Sum1toN (3); val it = 6 : int - - Sum1toN (35); val it = 630 : int - - Sum1toN (~2); GC #0.0.0.0.2.13: (10 ms) GC #0.0.0.1.3.17: (110 ms) GC #0.0.1.2.4.19: (180 ms) GC #0.1.2.3.5.23: (230 ms) GC #1.2.3.4.6.25: (330 ms) GC #2.3.4.5.7.29: (360 ms) GC #2.4.5.6.8.31: (140 ms) GC #2.5.6.7.9.35: (120 ms) GC #2.6.7.8.10.37: (110 ms) /local/ml-109.27/bin/.run/run.x86-linux: Error -- unable to map 10551296 bytes, errno = 12 /local/ml-109.27/bin/.run/run.x86-linux: Error -- unable to allocate to-space for generation 5; trying smaller size [...] GC #5.9.10.11.13.47: (680 ms) /local/ml-109.27/bin/.run/run.x86-linux: Fatal error -- unable to allocate minimum size trutta[1][cs171] > trutta[1][cs171] >sml Standard ML of New Jersey, Version 109.27, April 20, 1997 - - val MyList = [1, 3, 4, 2, 1, 5, 3]; val MyList = [1,3,4,2,1,5,3] : int list - - hd(MyList); val it = 1 : int - - tl(MyList); val it = [3,4,2,1,5,3] : int list - - 5 * (4 - hd(MyList)); val it = 15 : int - - 5 * (4 - tl(MyList)); stdIn:15.5-15.21 Error: operator and operand don't agree [literal] operator domain: int * int operand: int * int list in expression: - : overloaded ((4 : int),tl (MyList)) - - 4 + hd( tl(MyList)); val it = 7 : int - - hd( tl( tl( tl( MyList )))); val it = 2 : int - - val List2 = [3.4, 2.3]; val List2 = [3.4,2.3] : real list - - length(List2); val it = 2 : int - - tl(List2); val it = [2.3] : real list - - 4.3+tl(List2); stdIn:27.1-27.14 Error: operator and operand don't agree [tycon mismatch] operator domain: real * real operand: real * real list in expression: + : overloaded (4.3,tl (List2)) - - 4.3 + hd(tl(List2)); val it = 6.6 : real - - tl(tl(List2)); val it = [] : real list - - tl(tl(tl(List2))); uncaught exception Empty raised at: boot/list.sml:39.38-39.43 - - null(List2); val it = false : bool - - null(tl(tl(List2))); val it = true : bool - - fun sum(List:int list) = = if null(List) then = 0 = else = hd(List) + sum(tl(List)); val sum = fn : int list -> int - - sum(MyList); val it = 19 : int - - 6 + 5 * sum(MyList); val it = 101 : int - - sum ([]); val it = 0 : int - - fun sum(List:int list) = = if null(List) then = 0 = else = hd(List) + sum(List); val sum = fn : int list -> int - - sum(MyList); GC #0.0.0.0.3.89: (10 ms) GC #0.0.0.1.4.96: (50 ms) GC #0.0.1.2.5.116: (120 ms) GC #0.1.2.3.6.132: (210 ms) GC #1.2.3.4.7.152: (290 ms) GC #1.3.4.5.8.168: (230 ms) GC #2.4.5.6.9.188: (420 ms) GC #2.5.6.7.10.204: (230 ms) GC #2.6.7.8.11.224: (260 ms) /local/ml-109.27/bin/.run/run.x86-linux: Error -- unable to map 12386304 bytes, errno = 12 /local/ml-109.27/bin/.run/run.x86-linux: Error -- unable to allocate to-space for generation 5; trying smaller size GC #3.7.8.9.12.240: (600 ms) /local/ml-109.27/bin/.run/run.x86-linux: Error -- unable to map 30212096 bytes, errno = 12 /local/ml-109.27/bin/.run/run.x86-linux: Error -- unable to allocate to-space for generation 5; trying smaller size GC #4.8.9.10.13.260: Killed trutta[137][cs171] >