For this example, we shall define trees as `rose trees':
type rose_tree alpha == alpha # list(rose_tree alpha);A tree consists of a label and a list of sub-trees. (Note that this particular implementation permits recursive type synonym definitions.)
We wish to construct the list the labels in breadth-first order. The method used is:
uses lists, functions, products; dec bf_list : rose_tree alpha -> list alpha; --- bf_list t <= [t]. iterate (concat o map snd). front_with (/= []). concat. map fst;
bf_list (1, [(2, [(5, []), (6, [(10, [])]) ]), (3, [(7, [])]), (4, [(8, [(11, [])]), (9, []) ]) ]);