Next: Data Structures in General
Up: Adding Computation Domains: CLP
Previous: Constructing Recursive Data Structures:
-
- A binary tree with a piece of information in each node:
-
- Use, for example, the functor tree/3
- Its first argument is the item of information
- The second and third ones are the left and right sons
(subtrees)
- Use the constant void for empty trees
-
- is_tree(void).
is_tree(tree(Info, Left, Right):-
is_tree(Left),
is_tree(Right).
-
- 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>