equal
deleted
inserted
replaced
28 |
28 |
29 datatype 'a up\<^sub>i = T\<^sub>i "'a tree23" | Up\<^sub>i "'a tree23" 'a "'a tree23" |
29 datatype 'a up\<^sub>i = T\<^sub>i "'a tree23" | Up\<^sub>i "'a tree23" 'a "'a tree23" |
30 |
30 |
31 fun tree\<^sub>i :: "'a up\<^sub>i \<Rightarrow> 'a tree23" where |
31 fun tree\<^sub>i :: "'a up\<^sub>i \<Rightarrow> 'a tree23" where |
32 "tree\<^sub>i (T\<^sub>i t) = t" | |
32 "tree\<^sub>i (T\<^sub>i t) = t" | |
33 "tree\<^sub>i (Up\<^sub>i l p r) = Node2 l p r" |
33 "tree\<^sub>i (Up\<^sub>i l a r) = Node2 l a r" |
34 |
34 |
35 fun ins :: "'a::cmp \<Rightarrow> 'a tree23 \<Rightarrow> 'a up\<^sub>i" where |
35 fun ins :: "'a::cmp \<Rightarrow> 'a tree23 \<Rightarrow> 'a up\<^sub>i" where |
36 "ins x Leaf = Up\<^sub>i Leaf x Leaf" | |
36 "ins x Leaf = Up\<^sub>i Leaf x Leaf" | |
37 "ins x (Node2 l a r) = |
37 "ins x (Node2 l a r) = |
38 (case cmp x a of |
38 (case cmp x a of |
70 "insert x t = tree\<^sub>i(ins x t)" |
70 "insert x t = tree\<^sub>i(ins x t)" |
71 |
71 |
72 datatype 'a up\<^sub>d = T\<^sub>d "'a tree23" | Up\<^sub>d "'a tree23" |
72 datatype 'a up\<^sub>d = T\<^sub>d "'a tree23" | Up\<^sub>d "'a tree23" |
73 |
73 |
74 fun tree\<^sub>d :: "'a up\<^sub>d \<Rightarrow> 'a tree23" where |
74 fun tree\<^sub>d :: "'a up\<^sub>d \<Rightarrow> 'a tree23" where |
75 "tree\<^sub>d (T\<^sub>d x) = x" | |
75 "tree\<^sub>d (T\<^sub>d t) = t" | |
76 "tree\<^sub>d (Up\<^sub>d x) = x" |
76 "tree\<^sub>d (Up\<^sub>d t) = t" |
77 |
77 |
78 (* Variation: return None to signal no-change *) |
78 (* Variation: return None to signal no-change *) |
79 |
79 |
80 fun node21 :: "'a up\<^sub>d \<Rightarrow> 'a \<Rightarrow> 'a tree23 \<Rightarrow> 'a up\<^sub>d" where |
80 fun node21 :: "'a up\<^sub>d \<Rightarrow> 'a \<Rightarrow> 'a tree23 \<Rightarrow> 'a up\<^sub>d" where |
81 "node21 (T\<^sub>d t1) a t2 = T\<^sub>d(Node2 t1 a t2)" | |
81 "node21 (T\<^sub>d t1) a t2 = T\<^sub>d(Node2 t1 a t2)" | |