| author | wenzelm |
| Tue, 12 Jan 2016 20:05:53 +0100 | |
| changeset 62155 | ec2f0dad8b98 |
| parent 61224 | 759b5299a9f2 |
| child 62160 | ff20b44b2fc8 |
| permissions | -rw-r--r-- |
| 61224 | 1 |
theory Tree2 |
2 |
imports Main |
|
3 |
begin |
|
4 |
||
5 |
datatype ('a,'b) tree =
|
|
6 |
Leaf ("\<langle>\<rangle>") |
|
|
7 |
Node 'b "('a,'b)tree" 'a "('a,'b) tree" ("\<langle>_, _, _, _\<rangle>")
|
|
8 |
||
9 |
fun inorder :: "('a,'b)tree \<Rightarrow> 'a list" where
|
|
10 |
"inorder Leaf = []" | |
|
11 |
"inorder (Node _ l a r) = inorder l @ a # inorder r" |
|
12 |
||
13 |
fun height :: "('a,'b) tree \<Rightarrow> nat" where
|
|
14 |
"height Leaf = 0" | |
|
15 |
"height (Node _ l a r) = max (height l) (height r) + 1" |
|
16 |
||
17 |
end |