Set Utilities #19
Aliases: Set Utilities, set_utilities
9 verbs · 11 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
union | this none this | rxd | #19 | 11 |
intersection | this none this | rxd | #19 | 22 |
diff*erence | this none this | rxd | #19 | 9 |
contains | this none this | rxd | #19 | 12 |
exclusive_or xor | this none this | rxd | #19 | 19 |
difference_suspended diff_suspended | this none this | rxd | #19 | 11 |
equal | this none this | rxd | #19 | 22 |
intersection_preserve_case | this none this | rxd | #19 | 14 |
subtract | this none this | rxd | #19 | 6 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
help_msg | #72 | rc | #29 | list of 22{"This object is useful for operations that treat lists as sets (i.e.,", "without concern about order and assuming no duplication).", "", " union(set, set, ...) => union", " intersection(set, set, ...) => intersection", " intersection_preserve_case(base set, set, set, ...)", " => intersection with the case of the base set's elements preserved", "", " diff*erence(set1, set2, ..., setn)", " => result of removing all elements of sets 2..n from set 1.", "", " difference_suspended(set1, set2, ..., setn)", " => same as above except it suspends as needed.", "", " exclusive_or(set, set, set, ...)", " => all elements that are contained in exactly one of the sets", "", " contains(set1, set2, ..., setn)", " => true if and only if all of sets 2..n are subsets of set 1", "", " equal(set1, set2)", " => true if and only if set1 and set2 are equal"} |
aliases | #1 | rc | #29 | {"Set Utilities", "set_utilities"} |
description | #1 | rc | #29 | {"This is the Set Utilities utility package. See `help $set_utils' for more details."} |
object_size | #1 | r | #29 | {6097, 1298433815} |
hidden_verbs | #1 | rc | #29 | <clear> |
phelp_msg | #1 | rc | #29 | <clear> |
weight | #1 | rc | #29 | <clear> |
owner_verbs | #1 | rc | #29 | <clear> |
plural_name | #1 | rc | #29 | <clear> |
client_image | #1 | rc | #29 | <clear> |
listening | #1 | rc | #29 | <clear> |
Ancestry
Ancestors (nearest first): #72 Generic Utilities Package → #1 root
Children: none
Call graph
Source
union
Referenced by
- #293:do_combine line 16:
$set_utils:union - #293:do_combine line 18:
$set_utils:union
Source
1"Returns the set union of all of the lists provided as arguments."; 2if (!args) 3return {}; 4endif 5{set, @rest} = args; 6for l in (rest) 7for x in (l) 8set = setadd(set, x); 9endfor 10endfor 11return set;
intersection
Referenced by
- #4:w*ho line 18:
$set_utils:intersection - #76:help_msg line 16:
$set_utils:intersection - #137:old_users_msg line 33:
$set_utils:intersection - #137:old_users_msg line 38:
$set_utils:intersection - #317:@compare line 45:
$set_utils:intersection - #317:@compare line 132:
$set_utils:intersection
Source
1"Returns the set intersection of all the lists provided as arguments."; 2if (!args) 3return {}; 4endif 5max = 0; 6{result, @rest} = args; 7for set in (rest) 8if (length(result) < length(set)) 9set1 = result; 10set2 = set; 11else 12set1 = set; 13set2 = result; 14endif 15for x in (set1) 16if (!(x in set2)) 17set1 = setremove(set1, x); 18endif 19endfor 20result = set1; 21endfor 22return result;
diff*erence
Referenced by
none
Source
1"Usage: diff(set 1, set 2, ..., set n)"; 2"Returns all elements of set 1 that are not in sets 2..n"; 3{set, @rest} = args; 4for l in (rest) 5for x in (l) 6set = setremove(set, x); 7endfor 8endfor 9return set;
contains
Referenced by
none
Source
1"True if the first list given is a superset of all subsequent lists."; 2"False otherwise. {} is a superset of {} and nothing else; anything is"; 3"a superset of {}. If only one list is given, return true."; 4{?super = {}, @rest} = args; 5for l in (rest) 6for x in (l) 7if (!(x in super)) 8return 0; 9endif 10endfor 11endfor 12return 1;
exclusive_or xor
Referenced by
none
Source
1"Usage: exclusive_or(set, set, ...)"; 2"Return the set of all elements that are in exactly one of the input sets"; 3"For two sets, this is the equivalent of (A u B) - (A n B)."; 4if (!args) 5return {}; 6endif 7{set, @rest} = args; 8so_far = set; 9for l in (rest) 10for x in (l) 11if (x in so_far) 12set = setremove(set, x); 13else 14set = setadd(set, x); 15endif 16endfor 17so_far = {@so_far, @l}; 18endfor 19return set;
difference_suspended diff_suspended
Referenced by
none
Source
1"Usage: diff_suspended(set 1, set 2, ..., set n)"; 2"Returns all elements of set 1 that are not in sets 2..n"; 3"Suspends as needed if the lists are large."; 4{set, @rest} = args; 5for l in (rest) 6for x in (l) 7set = setremove(set, x); 8$command_utils:suspend_if_needed(0); 9endfor 10endfor 11return set;
equal
Referenced by
none
Source
1"True if the two lists given contain the same elements."; 2"False otherwise."; 3{set1, set2} = args; 4while (set1) 5{elt, @set1} = set1; 6if (elt in set2) 7set2 = setremove(set2, elt); 8while (elt in set2) 9set2 = setremove(set2, elt); 10endwhile 11while (elt in set1) 12set1 = setremove(set1, elt); 13endwhile 14else 15return 0; 16endif 17endwhile 18if (set2) 19return 0; 20else 21return 1; 22endif
intersection_preserve_case
Referenced by
none
Source
1"Copied from Fox (#54902):intersection Mon Dec 27 17:02:57 1993 PST"; 2"a version of $set_utils:intersection that maintains the property that everything in the return value is in the first argument, even considering case"; 3if (!args) 4return {}; 5endif 6{result, @rest} = args; 7for s in (rest) 8for x in (result) 9if (!(x in s)) 10result = setremove(result, x); 11endif 12endfor 13endfor 14return result;
subtract
Referenced by
none
Source
1set1 = args[1]; 2set2 = args[2]; 3for x in (set2) 4set1 = setremove(set1, x); 5endfor 6return set1;