(*Uma Nota: o tipo Set que OCaml fornece é implementado como arvores AVL *) type 'a avl = Empty Node of int * 'a avl * 'a * 'a avl (*Algumas funções auxiliares úteis*) let empty () = Empty let isEmpty tree = tree = Empty let rec member comp e t = match t with Node (_,l,x,r) -> (match comp e x with -1 -> member comp e l 0 -> true _ -> member comp e r ) Empty -> false let depth tree = match tree with Node (d, _, _, _) -> d Empty -> 0 let value tree = match tree with Node (_, _, x, _) -> x Empty -> failwith "Impossible"
This document was generated using caml2html