next up previous
Next: Data Structures in General Up: Adding Computation Domains: CLP Previous: Constructing Recursive Data Structures:

Constructing Recursive Data Structures: Trees

  $\mbox{$\bullet$}$
A binary tree with a piece of information in each node:
  $\mbox{$\bullet$}$
Use, for example, the functor tree/3
is_tree(void).
is_tree(tree(Info, Left, Right):- is_tree(Left),
is_tree(Right).
  $\mbox{$\bullet$}$
Membership:
tree_member(Element, tree(Element, L, R)).
tree_member(Element, tree(E, L, R)):-
tree_member(Element, L).
tree_member(Element, tree(E, L, R)):-
tree_member(Element, R).



Last modification: Thu Oct 7 12:04:03 MEST 1999 <webmaster@clip.dia.fi.upm.es>