1struct::set(n)                Tcl Data Structures               struct::set(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       struct::set - Procedures for manipulating sets
9

SYNOPSIS

11       package require Tcl  8.0
12
13       package require struct::set  ?2.1.1?
14
15       ::struct::set empty set
16
17       ::struct::set size set
18
19       ::struct::set contains set item
20
21       ::struct::set union ?set1...?
22
23       ::struct::set intersect ?set1...?
24
25       ::struct::set difference set1 set2
26
27       ::struct::set symdiff set1 set2
28
29       ::struct::set intersect3 set1 set2
30
31       ::struct::set equal set1 set2
32
33       ::struct::set include svar item
34
35       ::struct::set exclude svar item
36
37       ::struct::set add svar set
38
39       ::struct::set subtract svar set
40
41       ::struct::set subsetof A B
42
43_________________________________________________________________
44

DESCRIPTION

46       The  ::struct::set  namespace contains several useful commands for pro‐
47       cessing finite sets.
48
49       It exports only a single command, struct::set. All  functionality  pro‐
50       vided here can be reached through a subcommand of this command.
51

COMMANDS

53       ::struct::set empty set
54              Returns  a  boolean value indicating if the set is empty (true),
55              or not (false).
56
57       ::struct::set size set
58              Returns an integer number greater than or equal to zero. This is
59              the number of elements in the set. In other words, its cardinal‐
60              ity.
61
62       ::struct::set contains set item
63              Returns a boolean value indicating if the set contains the  ele‐
64              ment item (true), or not (false).
65
66       ::struct::set union ?set1...?
67              Computes  the set containing the union of set1, set2, etc., i.e.
68              "set1 + set2 + ...", and returns this set as the result  of  the
69              command.
70
71       ::struct::set intersect ?set1...?
72              Computes  the  set  containing  the  intersection of set1, set2,
73              etc., i.e. "set1 * set2 * ...", and  returns  this  set  as  the
74              result of the command.
75
76       ::struct::set difference set1 set2
77              Computes  the  set  containing  the difference of set1 and set2,
78              i.e. ("set1 - set2") and returns this set as the result  of  the
79              command.
80
81       ::struct::set symdiff set1 set2
82              Computes the set containing the symmetric difference of set1 and
83              set2, i.e. ("(set1 - set2) + (set2 - set1)")  and  returns  this
84              set as the result of the command.
85
86       ::struct::set intersect3 set1 set2
87              This  command is a combination of the methods intersect and dif‐
88              ference.    It   returns   a   three-element   list   containing
89              "set1*set2",  "set1-set2",  and  "set2-set1",  in this order. In
90              other words, the intersection of the  two  parameter  sets,  and
91              their differences.
92
93       ::struct::set equal set1 set2
94              Returns  a  boolean  value  indicating if the two sets are equal
95              (true) or not (false).
96
97       ::struct::set include svar item
98              The element item is added to the set specified by  the  variable
99              name  in svar. The return value of the command is empty. This is
100              the equivalent of lappend for sets.
101
102       ::struct::set exclude svar item
103              The element item is removed from the set specified by the  vari‐
104              able  name  in  svar.  The return value of the command is empty.
105              This is a near-equivalent of lreplace for sets.
106
107       ::struct::set add svar set
108              All the element of set are added to the  set  specified  by  the
109              variable name in svar. The return value of the command is empty.
110              This is like the method include, but for the addition of a whole
111              set.
112
113       ::struct::set subtract svar set
114              All the element of set are removed from the set specified by the
115              variable name in svar. The return value of the command is empty.
116              This  is like the method exclude, but for the removal of a whole
117              set.
118
119       ::struct::set subsetof A B
120              Returns a boolean value indicating if the set A is a true subset
121              of or equal to the set B (true), or not (false).
122

REFERENCES

KEYWORDS

125       cardinality, difference, emptiness, exclusion, inclusion, intersection,
126       membership, set, symmetric difference, union
127
129       Copyright (c) 2004 Andreas Kupries <andreas_kupries@users.sourceforge.net>
130
131
132
133
134struct                               2.1.1                      struct::set(n)
Impressum