Reade 7.3 The "order" function can be defined outside the "ordintlist" definition: fun order [] = nil_oil | order (a::x) = insert_oil a (order x); So, the inside "order" is redundant in this sense. But the implementation of the inside "order" can be more efficient because it knows the representation of oil's. In particular, it can use quicksort to sort the entire list at once, whereas the outside implementation above effectively does an insertion sort. 7.4 fun list_oil oil = rev (acc_oil consonto [] oil); (assuming we want the list to come out in sorted order) 7.6 local datatype int_tree = Empty | Tr of (int_tree * int * int_tree); fun insert n Empty = Tr(Empty, n, Empty) | insert n (Tr(l,a,r)) = if (lessthan a) n then Tr((insert n l),a,r) else Tr(l,a,(insert n r)) fun tail Empty = error "tl_oil of nil_oil" | tail (Tr(Empty,a,r)) = r | tail (Tr(l,a,r)) = Tr((tail l),a,r) fun head (Tr(Empty,a,r)) = a | head (Tr(l,a,r)) = head l | head Empty = error "hd_oil of nil_oil" fun sort Empty = Empty | sort x = insert (head x) (sort (tail x)) in abstype ordintlist = Ordered of int_tree with fun null_oil (Ordered Empty) = true | null_oil (Ordered (Tr(l,a,r))) = false val nil_oil = Ordered Empty fun hd_oil (Ordered x) = head x fun tl_oil (Ordered x) = Ordered (tail x) fun insert_oil n (Ordered x) = Ordered (insert n x) fun order x = Ordered (sort x) end end; Ullman 15.4 signature NEW_TTT = sig type tttree; type oneOrTwo; fun create : int -> tttree; fun lookup : int * tttree -> bool; fun groupUT ... . . . end; abstraction New_TTTree: NEW_TTT = TTTree; 15.5 abstype tttree = Two of int * tttree * tttree | Three of int * int * tttree * tttree * tttree | Leaf of int and oneOrTwo = S of tttree | P of int * tttree * tttree with fun groupUT... fun creat(i) = Leaf(i) fun lookup(x, Leaf(i)) ... fun insert1(x, Leaf(i)) ... fun unwrap... fun insert... end; 16.1(b) val A = array(100,0.0); (d) sub(A,9); (f) update(A,0,[1,2,3]); 17.1(b) val word = ref "foo"; (d) dec(j); or j := !j - 1; (f) word := "bar";