set(n) Tcl Data Structures set(n)
NAME
set - Procedures for manipulating sets
SYNOPSIS
package require Tcl 8.00
package require struct ??2.00??
::::struct::::set empty set
::::struct::::set size set
::::struct::::set contains set item
::::struct::::set union ?set1...?
::::struct::::set intersect ?set1...?
::::struct::::set difference set1 set2
::::struct::::set symdiff set1 set2
::::struct::::set intersect3 set1 set2
::::struct::::set equal set1 set2
DESCRIPTION
The ::::struct::::set namespace contains several useful commands for pro-
cessing finite sets.
It exports only a single command, struct::::set. All functionality pro-
vided here can be reached through a subcommand of this command.
COMANDS
::::struct::::set empty set
Returns a boolean value indicating if the set is empty (true),
or not (false).
::::struct::::set size set
Returns an integer number greater than or equal to zero. This is
the number of elements in the set. In other words, its cardinal-
ity.
::::struct::::set contains set item
Returns a boolean value indicating if the set contains the ele-
ment item (true), or not (false).
::::struct::::set union ?set1...?
Computes the set containing the union of set1, set2, etc., i.e.
"set1 ] set2 ] ...", and returns this set as the result of the
command.
::::struct::::set intersect ?set1...?
Computes the set containing the intersection of set1, set2,
etc., i.e. "set1 * set2 * ...", and returns this set as the
result of the command.
::::struct::::set difference set1 set2
Computes the set containing the difference of set1 and set2,
i.e. ("set1 - set2") and returns this set as the result of the
command.
::::struct::::set symdiff set1 set2
Computes the set containing the symmetric difference of set1 and
set2, i.e. ("(set1 - set2) ] (set2 - set1)") and returns this
set as the result of the command.
::::struct::::set intersect3 set1 set2
This command is a combination of the methods intersect and dif-
ference. It returns a three-element list containing
"set1*set2", "set1-set2", and "set2-set1", in this order. In
other words, the intersection of the two parameter sets, and
their differences.
::::struct::::set equal set1 set2
Returns a boolean value indicating if the two sets are equal
(true) or not (false).
REFERENCES
KEYWORDS
cardinality, difference, emptiness, intersection, membership, set, sym-
metric difference, union
COPYRIGHT
Copyright (c) 2004 Andreas Kupries
struct 2.0 set(n)
|