root/tags/lgt2311/library/setp.lgt

Revision 3687, 3.3 KB (checked in by pmoura, 21 months ago)

Code reformating.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2:- protocol(setp).
3
4    :- info([
5        version is 1.0,
6        author is 'Paulo Moura',
7        date is 2000/7/24,
8        comment is 'Set protocol.']).
9
10    :- public(delete/3).
11    :- mode(delete(+set, @term, ?set), one).
12    :- info(delete/3,
13        [comment is 'Deletes an element from a set returning the set of remaining elements.',
14         argnames is ['Set', 'Element', 'Remaining']]).
15
16    :- public(disjoint/2).
17    :- mode(disjoint(+set, +set), zero_or_one).
18    :- info(disjoint/2, [
19        comment is 'True if the two sets have no element in common.',
20        argnames is ['Set1', 'Set2']]).
21
22    :- public(equal/2).
23    :- mode(equal(+set, +set), zero_or_one).
24    :- info(equal/2, [
25        comment is 'True if the two sets are equal.',
26        argnames is ['Set1', 'Set2']]).
27
28    :- public(empty/1).
29    :- mode(empty(+set), zero_or_one).
30    :- info(empty/1, [
31        comment is 'True if the set is empty.',
32        argnames is ['Set']]).
33
34    :- public(insert/3).
35    :- mode(insert(+set, +term, ?set), one).
36    :- info(insert/3, [
37        comment is 'Inserts an element in a set, returning the resulting set.',
38        argnames is ['In', 'Element', 'Out']]).
39
40    :- public(insert_all/3).
41    :- mode(insert_all(+list, +set, ?set), one).
42    :- info(insert_all/3, [
43        comment is 'Inserts a list of elemnts in a set, returning the resulting set.',
44        argnames is ['List', 'In', 'Out']]).
45
46    :- public(intersect/2).
47    :- mode(intersect(+set, +set), zero_or_one).
48    :- info(intersect/2, [
49        comment is 'True if the two sets have at least one element in common.',
50        argnames is ['Set1', 'Set2']]).
51
52    :- public(intersection/3).
53    :- mode(intersection(+set, +set, ?set), zero_or_one).
54    :- info(intersection/3, [
55        comment is 'Returns the intersection of Set1 and Set2.',
56        argnames is ['Set1', 'Set2', 'Intersection']]).
57
58    :- public(length/2).
59    :- mode(length(+set, ?integer), zero_or_one).
60    :- info(length/2,
61        [comment is 'Number of set elements.',
62         argnames is ['Set', 'Length']]).
63
64    :- public(member/2).
65    :- mode(member(+term, +set), zero_or_one).
66    :- mode(member(-term, +set), zero_or_more).
67    :- info(member/2,
68        [comment is 'Element is a member of set Set.',
69         argnames is ['Element', 'Set']]).
70
71    :- public(powerset/2).
72    :- mode(powerset(+set, -list), one).
73    :- info(powerset/2,
74        [comment is 'Returns the power set of a set, represented as a list of sets.',
75         argnames is ['Set', 'Powerset']]).
76
77    :- public(select/3).
78    :- mode(select(?term, +set, ?set), zero_or_more).
79    :- info(select/3,
80        [comment is 'Selects an element from a set, returning the set of remaining elements.',
81         argnames is ['Element', 'Set', 'Remaining']]).
82
83    :- public(subset/2).
84    :- mode(subset(+set, +set), zero_or_one).
85    :- info(subset/2, [
86        comment is 'True if Subset is a subset of Set.',
87        argnames is ['Subset', 'Set']]).
88
89    :- public(subtract/3).
90    :- mode(subtract(+set, +set, ?set), zero_or_one).
91    :- info(subtract/3, [
92        comment is 'True when Difference contains all and only the elements of Set1 which are not also in Set2.',
93        argnames is ['Set1', 'Set2', 'Difference']]).
94
95    :- public(symdiff/3).
96    :- mode(symdiff(+set, +set, ?set), zero_or_one).
97    :- info(symdiff/3, [
98        comment is 'True if Difference is the symmetric difference of Set1 and Set2.',
99        argnames is ['Set1', 'Set2', 'Difference']]).
100
101    :- public(union/3).
102    :- mode(union(+set, +set, ?set), zero_or_one).
103    :- info(union/3, [
104        comment is 'True if Union is the union of Set1 and Set2.',
105        argnames is ['Set1', 'Set2', 'Union']]).
106
107:- end_protocol.
Note: See TracBrowser for help on using the browser.