(* Collect the leaves of a binary tree in a list A leaf is a node with no successors. Write a predicate leaves/2 to collect them in a list. % leaves(T,S) :- S is the list of all leaves of the binary tree T *) type bin_tree = Leaf of string | Node of string * bin_tree * bin_tree ;; let rec collect_leaves t = match t with Leaf(s) -> [s] | Node(s,tl,tr) -> List.append (collect_leaves tl) (collect_leaves tr) ;;