#beginc void print_int(int x) { printf("%i",x); return; } void newline() { printf("\n"); return; } #endc prog datatype tree = Leaf of int | Node of int * tree * tree dec unit print_int(int i) dec unit newline() def tree build(int depth) = if (depth=0) then Leaf(depth) else Node(depth,build(depth-1)@new(<>),build(depth-1)@new(<>)) def tree mirror(tree t) = match t with Leaf(i) -> Leaf(i) | Node(i,t1@d1,t2@d2) -> Node(i,mirror(t2)@d1,mirror(t1)@d2) def unit print_tree(tree t) = match t with Leaf(i) -> print_int(i) | Node(i,t1@d1,t2@d2) -> (print_int(i); print_tree(t1); print_tree(t2)) def int main() = let d = 12 in let t = build(d) in let m = mirror(t) in (print_tree(m); 1) end