3 # sneek preview for the world!
8 typedef Tree a := Tip | Bin a (Tree a) (Tree a)
10 # functions are invoked as 'insert(x, y)'
11 func insert : a (Tree a) -> (Tree a)
12 insert(x, Tip) = Bin x Tip Tip
13 insert(x, Bin y l r) | x < y = Bin y insert(x, l) r
14 | otherwise = Bin y l insert(x, r)
16 # prefix operators work like normal functional functions
17 op prefix contains : a (Tree a) -> B
18 contains x Tip = False
19 contains x (Bin y l r) | x == y = True
20 | x < y = contains x l
21 | otherwise = contains x r
23 op prefix len : [a] -> N
25 len [_:xs] = 1 + (len xs)
27 # currently no way to specify binding strenght
28 op infix -- : N N -> B
33 max(x, y) | x -- y = y
35 | otherwise = y # equals