struct::set(n)
π struct::set(n) β Tcl Data Structures π
okay bestie, gather round, because we're talking about struct::set, the Tcl Data Structures era of your life that you didn't know you needed. it's giving math class but make it cute. it's giving finite sets and zero drama. let's GO. π
β¨ NAME β¨
struct::set β procedures for manipulating sets π
π¦ SYNOPSIS π¦
package require Tcl 8.5 9
package require struct::set ?2.2.4?
::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
::struct::set include svar item
::struct::set exclude svar item
::struct::set add svar set
::struct::set subtract svar set
::struct::set subsetof A B
πΈ DESCRIPTION πΈ
so the ::struct::set namespace is literally just a little home for several genuinely useful commands that process finite sets. that's it. that's the vibe. no cap. β¨
it exports exactly one command, struct::set, and all the functionality lives as subcommands under it. one command, many talents. main character energy fr fr. π
note bestie: as of version 2.2 of this package, a critcl-based C implementation is available. HOWEVER (and this is important) that implementation requires Tcl 8.4 to run. so, like, keep that in mind. π«Ά
π COMMANDS π
::struct::set empty setβ returns a boolean telling you if the set is empty (true) or not (false). it's the vibe check for "is there literally anything in here". π³οΈ::struct::set size setβ returns an integer greater than or equal to zero. it's the number of elements in the set β in other words, its cardinality. it's the headcount. the census. the "how many of us are here". π::struct::set contains set itemβ returns a boolean telling you if the set containsitem(true) or not (false). are they on the list or are they not on the list. ποΈ::struct::set union ?set1...?β computes the set containing the union ofset1,set2, etc., i.e."set1 + set2 + ...", and returns that set as the result of the command. everyone's invited, it's a group chat. π«::struct::set intersect ?set1...?β computes the set containing the intersection ofset1,set2, etc., i.e."set1 * set2 * ...", and returns that set as the result of the command. only the ones that showed up to every hangout. π₯::struct::set difference set1 set2β computes the set containing the difference ofset1andset2, i.e. ("set1 - set2"), and returns that set as the result of the command. it's who's inset1that is not inset2. π::struct::set symdiff set1 set2β computes the set containing the symmetric difference ofset1andset2, i.e. ("(set1 - set2) + (set2 - set1)"), and returns that set as the result of the command. the ones who are exclusive to exactly one side. it's giving "we don't overlap and that's fine". π¦::struct::set intersect3 set1 set2β this one is a combo ofintersectanddifference. 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. three for the price of one, ate. π::struct::set equal set1 set2β returns a boolean telling you if the two sets are equal (true) or not (false). same energy, same contents. β::struct::set include svar itemβ the elementitemis added to the set specified by the variable name insvar. the return value of the command is empty. this is the equivalent oflappendfor sets. if the variable named bysvardoes not exist, it will be created. β¨::struct::set exclude svar itemβ the elementitemis removed from the set specified by the variable name insvar. the return value of the command is empty. this is a near-equivalent oflreplacefor sets. bye bestie π::struct::set add svar setβ all the elements ofsetare added to the set specified by the variable name insvar. the return value of the command is empty. this is like theincludemethod, but for adding a whole set at once. if the variable named bysvardoes not exist, it will be created. π::struct::set subtract svar setβ all the elements ofsetare removed from the set specified by the variable name insvar. the return value of the command is empty. this is like theexcludemethod, but for removing a whole set. mass unfollow, but for math. π::struct::set subsetof A Bβ returns a boolean telling you if the setAis a true subset of, or equal to, the setB(true) or not (false). isAfully contained inB's world? π
π REFERENCES π
(this section is empty in the original β even icons need a breather) π§
π BUGS, IDEAS, FEEDBACK π
ngl, this document and the package it describes will undoubtedly contain bugs and other problems. it's fine. it's fine!! π please report such in the category struct :: set of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist.
please also report any ideas for enhancements you may have for either the package and/or the documentation. we want the glow-up. π«Ά
when proposing code changes, please provide unified diffs, i.e. the output of diff -u. no vibes-only patches, bestie.
note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. periodt. π
π KEYWORDS π
cardinality, difference, emptiness, exclusion, inclusion, intersection, membership, set, symmetric difference, union
π CATEGORY π
Data structures
π COPYRIGHT π
Copyright (c) 2004-2008 Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page, bestie!! this was brought to you by tcllib, version 2.2.5, under the name struct::set(n) β from the Tcl Data Structures section. mwah. stay set-theoretic. πβ¨π
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2004-2008 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms