root/tags/lgt293/library/proto_hierarchy.lgt

Revision 2, 1.4 KB (checked in by pmoura, 7 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2:- category(proto_hierarchy,
3    implements(proto_hierarchyp)).
4
5
6    :- info([
7        version is 1.0,
8        authors is 'Paulo Moura',
9        date is 2000/7/24,
10        comment is 'Prototype hierarchy predicates.']).
11
12
13    parent(Parent) :-
14        self(Self),
15        extends_object(Self, Parent).
16
17
18    parents(Parents) :-
19        self(Self),
20        findall(Parent, extends_object(Self, Parent), Parents).
21
22
23    ancestor(Ancestor) :-
24        self(Self),
25        ancestor(Self, Ancestor).
26
27
28    ancestor(Self, Ancestor) :-
29        extends_object(Self, Ancestor).
30
31    ancestor(Self, Ancestor) :-
32        extends_object(Self, Parent),
33        ancestor(Parent, Ancestor).
34
35
36    ancestors(Ancestors) :-
37        self(Self),
38        findall(Ancestor, ancestor(Self, Ancestor), Ancestors).
39
40
41    leaf(Leaf) :-
42        self(Self),
43        leaf(Self, Leaf).
44
45
46    leaf(Self, Leaf) :-
47        extends_object(Leaf, Self),
48        \+ extends_object(_, Leaf).
49
50    leaf(Self, Leaf) :-
51        extends_object(Object, Self),
52        leaf(Object, Leaf).
53
54
55    leaves(Leaves) :-
56        self(Self),
57        findall(Leaf, leaf(Self, Leaf), Leaves).
58
59
60    descendant(Descendant) :-
61        self(Self),
62        descendant(Self, Descendant).
63
64
65    descendant(Self, Descendant) :-
66        extends_object(Descendant, Self).
67
68    descendant(Self, Descendant) :-
69        extends_object(Descendant, Self),
70        \+ extends_object(Descendant, Self).
71
72    descendant(Self, Descendant) :-
73        extends_object(Subclass, Self),
74        descendant(Subclass, Descendant).
75
76
77    descendants(Descendants) :-
78        self(Self),
79        findall(Descendant, descendant(Self, Descendant), Descendants).
80
81
82:- end_category.
Note: See TracBrowser for help on using the browser.