line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Set::Functional; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
82394
|
use 5.006; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
182
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
21
|
use Exporter qw{import}; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
9090
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Set::Functional - set operations for functional programming |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 1.04 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '1.04'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ |
20
|
|
|
|
|
|
|
setify setify_by |
21
|
|
|
|
|
|
|
cartesian |
22
|
|
|
|
|
|
|
difference difference_by |
23
|
|
|
|
|
|
|
disjoint disjoint_by |
24
|
|
|
|
|
|
|
distinct distinct_by |
25
|
|
|
|
|
|
|
intersection intersection_by |
26
|
|
|
|
|
|
|
symmetric_difference symmetric_difference_by |
27
|
|
|
|
|
|
|
union union_by |
28
|
|
|
|
|
|
|
is_disjoint is_disjoint_by |
29
|
|
|
|
|
|
|
is_equal is_equal_by |
30
|
|
|
|
|
|
|
is_equivalent is_equivalent_by |
31
|
|
|
|
|
|
|
is_pairwise_disjoint is_pairwise_disjoint_by |
32
|
|
|
|
|
|
|
is_proper_subset is_proper_subset_by |
33
|
|
|
|
|
|
|
is_proper_superset is_proper_superset_by |
34
|
|
|
|
|
|
|
is_subset is_subset_by |
35
|
|
|
|
|
|
|
is_superset is_superset_by |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => \@EXPORT_OK); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
This module provides basic set operations for native lists. The primary goal |
42
|
|
|
|
|
|
|
is to take advantage of Perl's native functional programming capabilities |
43
|
|
|
|
|
|
|
while relying solely on Pure Perl constructs to perform the set operations as |
44
|
|
|
|
|
|
|
fast as possible. All of these techniques have been benchmarked against other |
45
|
|
|
|
|
|
|
common Perl idioms to determine the optimal solution. These benchmarks can |
46
|
|
|
|
|
|
|
be found in this package (shortly). |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Each function is provided in two forms. The first form always expects simple |
49
|
|
|
|
|
|
|
flat data structures of defined elements. The second form expects a BLOCK |
50
|
|
|
|
|
|
|
(refered to as a choice function) to evaluate each member of the list to a |
51
|
|
|
|
|
|
|
defined value to determine how the element is a set member. These can be |
52
|
|
|
|
|
|
|
identified by the suffix "_by". None of these functions check definedness |
53
|
|
|
|
|
|
|
inline so as to eliminate the costly O(n) operation. All functions have been |
54
|
|
|
|
|
|
|
prototyped to give them a native Perl-ish look and feel. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Example usage: |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use Set::Functional ':all'; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Set Creation |
61
|
|
|
|
|
|
|
my @deduped_numbers = setify(1 .. 10, 2 .. 11); |
62
|
|
|
|
|
|
|
my @deduped_objects_by_name = setify_by { $_->{name} } ({name => 'fred'}, {name => 'bob'}, {name => 'fred'}); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Set Operation |
65
|
|
|
|
|
|
|
my @all_permutations = cartesian \@arr1, \@arr2, \@arr3, \@arr4; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my @only_arr1_elements = difference \@arr1, \@arr2, \@arr3, \@arr4; |
68
|
|
|
|
|
|
|
my @only_arr1_elements_by_name = difference_by { $_->{name} } \@arr1, \@arr2, \@arr3, \@arr4; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my @unique_per_set = disjoint \@arr1, \@arr2, \@arr3, \@arr4; |
71
|
|
|
|
|
|
|
my @unique_per_set_by_name = disjoint_by { $_->{name} } \@arr1, \@arr2, \@arr3, \@arr4; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my @unique_elements = distinct \@arr1, \@arr2, \@arr3, \@arr4; |
74
|
|
|
|
|
|
|
my @unique_elements_by_name = distinct_by { $_->{name} } \@arr1, \@arr2, \@arr3, \@arr4; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my @shared_elements = intersection \@arr1, \@arr2, \@arr3, \@arr4; |
77
|
|
|
|
|
|
|
my @shared_elements_by_name = intersection_by { $_->{name} } \@arr1, \@arr2, \@arr3, \@arr4; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my @odd_occuring_elements = symmetric_difference \@arr1, \@arr2, \@arr3, \@arr4; |
80
|
|
|
|
|
|
|
my @odd_occuring_elements_by_name = symmetric_difference_by { $_->{name} } \@arr1, \@arr2, \@arr3, \@arr4; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my @all_elements = union \@arr1, \@arr2, \@arr3, \@arr4; |
83
|
|
|
|
|
|
|
my @all_elements_by_name = union_by { $_->{name} } \@arr1, \@arr2, \@arr3, \@arr4; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Set Predicates |
86
|
|
|
|
|
|
|
my $is_all_of_arr1_distinct_from_arr2 = is_disjoint \@arr1, \@arr2; |
87
|
|
|
|
|
|
|
my $is_all_of_arr1_distinct_from_arr2_by_name = is_disjoint_by { $_->{name} } \@arr1, \@arr2; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $is_arr1_the_same_as_arr2 = is_equal \@arr1, \@arr2; |
90
|
|
|
|
|
|
|
my $is_arr1_the_same_as_arr2_by_name = is_equal_by { $_->{name} } \@arr1, \@arr2; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $are_all_sets_mutually_unique = is_pairwise_disjoint \@arr1, \@arr2, \@arr3, \@arr4; |
93
|
|
|
|
|
|
|
my $are_all_sets_mutually_unique_by_name = is_pairwise_disjoint_by { $_->{name} } \@arr1, \@arr2, \@arr3, \@arr4; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $is_all_of_arr1_in_arr2_but_not_the_same_as_arr2 = is_proper_subset \@arr1, \@arr2; |
96
|
|
|
|
|
|
|
my $is_all_of_arr1_in_arr2_but_not_the_same_as_arr2_by_name = is_proper_subset_by { $_->{name} } \@arr1, \@arr2; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $is_all_of_arr1_in_arr2 = is_subset \@arr1, \@arr2; |
99
|
|
|
|
|
|
|
my $is_all_of_arr1_in_arr2_by_name = is_subset_by { $_->{name} } \@arr1, \@arr2; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $is_all_of_arr2_in_arr1_but_not_the_same_as_arr1 = is_proper_superset \@arr1, \@arr2; |
102
|
|
|
|
|
|
|
my $is_all_of_arr2_in_arr1_but_not_the_same_as_arr1_by_name = is_proper_superset_by { $_->{name} } \@arr1, \@arr2; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $is_all_of_arr2_in_arr1 = is_superset \@arr1, \@arr2; |
105
|
|
|
|
|
|
|
my $is_all_of_arr2_in_arr1_by_name = is_superset_by { $_->{name} } \@arr1, \@arr2; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 CONSTRUCTORS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 setify(@) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Given a list, return a new set. Order is not guaranteed. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
setify 1 .. 10, 6 .. 15 => 1 .. 15 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub setify(@) { |
120
|
4
|
|
|
4
|
1
|
480
|
my %set; |
121
|
|
|
|
|
|
|
|
122
|
4
|
100
|
|
|
|
23
|
undef @set{@_} if @_; |
123
|
|
|
|
|
|
|
|
124
|
4
|
|
|
|
|
23
|
return keys %set; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 setify_by(&@) |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Given a choice function and a list, return a new set defined by the choice |
130
|
|
|
|
|
|
|
function. Order is not guaranteed. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub setify_by(&@){ |
135
|
4
|
|
|
4
|
1
|
2853
|
my $func = shift; |
136
|
|
|
|
|
|
|
|
137
|
4
|
|
|
|
|
6
|
my %set; |
138
|
|
|
|
|
|
|
|
139
|
4
|
100
|
|
|
|
11
|
@set{ map { $func->($_) } @_ } = @_ if @_; |
|
41
|
|
|
|
|
106
|
|
140
|
|
|
|
|
|
|
|
141
|
4
|
|
|
|
|
62
|
return values %set; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 OPERATORS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 cartesian(@) |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Given multiple set references, return multiple sets containing all permutations |
151
|
|
|
|
|
|
|
of one element from each set. If the empty set is provided, no sets are |
152
|
|
|
|
|
|
|
returned since the number of sets generated should be the product of the input |
153
|
|
|
|
|
|
|
sets' cardinalities. If no sets are provided then none are returned. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
cartesian [1 .. 3], [1 .. 2] => [1,1],[1,2],[2,1],[2,2],[3,1],[3,2] |
156
|
|
|
|
|
|
|
cartesin => () |
157
|
|
|
|
|
|
|
cartesin [1 .. 3], [] => () |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub cartesian(@) { |
162
|
7
|
100
|
|
7
|
1
|
332844
|
return unless @_; |
163
|
|
|
|
|
|
|
|
164
|
6
|
|
|
|
|
11
|
my @results; |
165
|
6
|
|
|
|
|
12
|
my $repetitions = 1; |
166
|
|
|
|
|
|
|
|
167
|
6
|
|
100
|
|
|
48
|
($repetitions *= @$_) || return for @_; |
168
|
4
|
|
|
|
|
32
|
$#results = $repetitions - 1; |
169
|
|
|
|
|
|
|
|
170
|
4
|
|
|
|
|
16
|
for my $idx (0 .. $#results) { |
171
|
2130
|
|
|
|
|
1977
|
$repetitions = @results; |
172
|
2130
|
|
|
|
|
2546
|
$results[$idx] = [map { $_->[int($idx/($repetitions /= @$_)) % @$_] } @_]; |
|
6610
|
|
|
|
|
14948
|
|
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
4
|
|
|
|
|
498
|
return @results; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 difference(@) |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Given multiple set references, return a new set with all the elements in the first set |
181
|
|
|
|
|
|
|
that don't exist in subsequent sets. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
difference [1 .. 10], [6 .. 15] => 1 .. 5 |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub difference(@) { |
188
|
5
|
|
|
5
|
1
|
1756
|
my $first = shift; |
189
|
|
|
|
|
|
|
|
190
|
5
|
100
|
66
|
|
|
40
|
return unless $first && @$first; |
191
|
|
|
|
|
|
|
|
192
|
4
|
|
|
|
|
5
|
my %set; |
193
|
|
|
|
|
|
|
|
194
|
4
|
|
|
|
|
21
|
undef @set{@$first}; |
195
|
|
|
|
|
|
|
|
196
|
4
|
100
|
|
|
|
9
|
do { delete @set{@$_} if @$_ } for @_; |
|
5
|
|
|
|
|
22
|
|
197
|
|
|
|
|
|
|
|
198
|
4
|
|
|
|
|
38
|
return keys %set; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 difference_by(&@) |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Given a choice function and multiple set references, return a new set with all the elements |
204
|
|
|
|
|
|
|
in the first set that don't exist in subsequent sets according to the choice function. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub difference_by(&@) { |
209
|
5
|
|
|
5
|
1
|
4431
|
my $func = shift; |
210
|
5
|
|
|
|
|
7
|
my $first = shift; |
211
|
|
|
|
|
|
|
|
212
|
5
|
100
|
66
|
|
|
25
|
return unless $first && @$first; |
213
|
|
|
|
|
|
|
|
214
|
4
|
|
|
|
|
5
|
my %set; |
215
|
|
|
|
|
|
|
|
216
|
4
|
|
|
|
|
10
|
@set{ map { $func->($_) } @$first } = @$first; |
|
40
|
|
|
|
|
91
|
|
217
|
|
|
|
|
|
|
|
218
|
4
|
100
|
|
|
|
529
|
do { delete @set{ map { $func->($_) } @$_ } if @$_ } for @_; |
|
5
|
|
|
|
|
22
|
|
|
40
|
|
|
|
|
78
|
|
219
|
|
|
|
|
|
|
|
220
|
4
|
|
|
|
|
32
|
return values %set; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 disjoint(@) |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Given multiple set references, return corresponding sets containing all the elements from |
226
|
|
|
|
|
|
|
the original set that exist in any set exactly once. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
disjoint [1 .. 10], [6 .. 15] => [1 .. 5], [11 .. 15] |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub disjoint(@) { |
233
|
10
|
|
|
10
|
1
|
3083
|
my %element_to_count; |
234
|
|
|
|
|
|
|
|
235
|
10
|
|
|
|
|
19
|
do { ++$element_to_count{$_} for @$_ } for @_; |
|
24
|
|
|
|
|
103
|
|
236
|
|
|
|
|
|
|
|
237
|
10
|
|
|
|
|
18
|
return map { [grep { $element_to_count{$_} == 1 } @$_] } @_; |
|
24
|
|
|
|
|
25
|
|
|
126
|
|
|
|
|
158
|
|
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 disjoint_by(&@) |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Given a choice function and multiple set references, return corresponding sets containing |
243
|
|
|
|
|
|
|
all the elements from the original set that exist in any set exactly once |
244
|
|
|
|
|
|
|
according to the choice function. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=cut |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub disjoint_by(&@) { |
249
|
10
|
|
|
10
|
1
|
6988
|
my $func = shift; |
250
|
|
|
|
|
|
|
|
251
|
10
|
|
|
|
|
13
|
my %key_to_count; |
252
|
|
|
|
|
|
|
|
253
|
10
|
|
|
|
|
21
|
do { ++$key_to_count{$func->($_)} for @$_ } for @_; |
|
24
|
|
|
|
|
226
|
|
254
|
|
|
|
|
|
|
|
255
|
10
|
|
|
|
|
102
|
return map { [grep { $key_to_count{$func->($_)} == 1 } @$_] } @_; |
|
24
|
|
|
|
|
62
|
|
|
126
|
|
|
|
|
291
|
|
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head2 distinct(@) |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Given multiple set references, return a new set containing all the elements that exist |
261
|
|
|
|
|
|
|
in any set exactly once. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
distinct [1 .. 10], [6 .. 15] => 1 .. 5, 11 .. 15 |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub distinct(@) { |
268
|
5
|
|
|
5
|
1
|
4052
|
my %element_to_count; |
269
|
|
|
|
|
|
|
|
270
|
5
|
|
|
|
|
13
|
do { ++$element_to_count{$_} for @$_ } for @_; |
|
9
|
|
|
|
|
53
|
|
271
|
|
|
|
|
|
|
|
272
|
5
|
|
|
|
|
21
|
return grep { $element_to_count{$_} == 1 } keys %element_to_count; |
|
56
|
|
|
|
|
68
|
|
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head2 distinct_by(&@) |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
Given a choice function and multiple set references, return a new set containing all the |
278
|
|
|
|
|
|
|
elements that exist in any set exactly once according to the choice function. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
sub distinct_by(&@) { |
283
|
5
|
|
|
5
|
1
|
5501
|
my $func = shift; |
284
|
|
|
|
|
|
|
|
285
|
5
|
|
|
|
|
9
|
my %key_to_count; |
286
|
|
|
|
|
|
|
|
287
|
5
|
|
|
|
|
12
|
for (@_) { |
288
|
9
|
|
|
|
|
18
|
for (@$_) { |
289
|
80
|
|
|
|
|
127
|
my $key = $func->($_); |
290
|
80
|
100
|
|
|
|
282
|
$key_to_count{$key} = exists $key_to_count{$key} ? undef : $_; |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
5
|
|
|
|
|
17
|
return grep { defined } values %key_to_count; |
|
56
|
|
|
|
|
91
|
|
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head2 intersection(@) |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Given multiple set references, return a new set containing all the elements that exist |
300
|
|
|
|
|
|
|
in all sets. |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
intersection [1 .. 10], [6 .. 15] => 6 .. 10 |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=cut |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub intersection(@) { |
307
|
53
|
|
|
53
|
1
|
3740
|
my $first = shift; |
308
|
|
|
|
|
|
|
|
309
|
53
|
100
|
100
|
|
|
230
|
return unless $first && @$first; |
310
|
|
|
|
|
|
|
|
311
|
40
|
|
|
|
|
39
|
my %set; |
312
|
|
|
|
|
|
|
|
313
|
40
|
|
|
|
|
111
|
undef @set{@$first}; |
314
|
|
|
|
|
|
|
|
315
|
40
|
|
|
|
|
55
|
for (@_) { |
316
|
41
|
|
|
|
|
57
|
my @int = grep { exists $set{$_} } @$_; |
|
190
|
|
|
|
|
245
|
|
317
|
41
|
100
|
|
|
|
79
|
return unless @int; |
318
|
28
|
|
|
|
|
43
|
%set = (); |
319
|
28
|
|
|
|
|
58
|
undef @set{@int}; |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
27
|
|
|
|
|
82
|
return keys %set; |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=head2 intersection_by(&@) |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
Given a choice function and multiple set references, return a new set containing all the |
328
|
|
|
|
|
|
|
elements that exist in all sets according to the choice function. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=cut |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
sub intersection_by(&@) { |
333
|
53
|
|
|
53
|
1
|
3873
|
my $func = shift; |
334
|
53
|
|
|
|
|
51
|
my $first = shift; |
335
|
|
|
|
|
|
|
|
336
|
53
|
100
|
100
|
|
|
210
|
return unless $first && @$first; |
337
|
|
|
|
|
|
|
|
338
|
40
|
|
|
|
|
35
|
my %set; |
339
|
|
|
|
|
|
|
|
340
|
40
|
|
|
|
|
63
|
@set{ map { $func->($_) } @$first } = @$first; |
|
220
|
|
|
|
|
456
|
|
341
|
|
|
|
|
|
|
|
342
|
40
|
|
|
|
|
238
|
for (@_) { |
343
|
41
|
|
|
|
|
74
|
my @int = grep { exists $set{$func->($_)} } @$_; |
|
190
|
|
|
|
|
406
|
|
344
|
41
|
100
|
|
|
|
157
|
return unless @int; |
345
|
28
|
|
|
|
|
47
|
%set = (); |
346
|
28
|
|
|
|
|
29
|
@set{ map { $func->($_) } @int } = @int; |
|
106
|
|
|
|
|
187
|
|
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
|
349
|
27
|
|
|
|
|
187
|
return values %set; |
350
|
|
|
|
|
|
|
} |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
=head2 symmetric_difference(@) |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
Given multiple set references, return a new set containing all the elements that |
355
|
|
|
|
|
|
|
exist an odd number of times across all sets. |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
symmetric_difference [1 .. 10], [6 .. 15], [4, 8, 12] => 1 .. 5, 8, 11 .. 15 |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
=cut |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
sub symmetric_difference(@) { |
362
|
5
|
|
|
5
|
1
|
3052
|
my $count; |
363
|
|
|
|
|
|
|
my %element_to_count; |
364
|
|
|
|
|
|
|
|
365
|
5
|
|
|
|
|
13
|
do { ++$element_to_count{$_} for @$_ } for @_; |
|
9
|
|
|
|
|
65
|
|
366
|
|
|
|
|
|
|
|
367
|
5
|
|
|
|
|
25
|
return grep { $element_to_count{$_} % 2 } keys %element_to_count; |
|
56
|
|
|
|
|
74
|
|
368
|
|
|
|
|
|
|
} |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
=head2 symmetric_difference_by(&@) |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
Given a choice function and multiple set references, return a new set containing |
373
|
|
|
|
|
|
|
all the elements that exist an odd number of times across all sets according to |
374
|
|
|
|
|
|
|
the choice function. |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=cut |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
sub symmetric_difference_by(&@) { |
379
|
5
|
|
|
5
|
1
|
6012
|
my $func = shift; |
380
|
|
|
|
|
|
|
|
381
|
5
|
|
|
|
|
6
|
my $count; |
382
|
|
|
|
|
|
|
my %key_to_count; |
383
|
|
|
|
|
|
|
|
384
|
5
|
|
|
|
|
10
|
do { ++$key_to_count{$func->($_)} for @$_ } for @_; |
|
9
|
|
|
|
|
120
|
|
385
|
|
|
|
|
|
|
|
386
|
80
|
|
|
|
|
89
|
return map { |
387
|
5
|
|
|
|
|
75
|
grep { |
388
|
9
|
|
|
|
|
13
|
$count = delete $key_to_count{$func->($_)}; |
389
|
80
|
100
|
|
|
|
293
|
defined($count) && $count % 2 |
390
|
|
|
|
|
|
|
} @$_ |
391
|
|
|
|
|
|
|
} @_; |
392
|
|
|
|
|
|
|
} |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=head2 union(@) |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
Given multiple set references, return a new set containing all the elements that exist |
397
|
|
|
|
|
|
|
in any set. |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
union [1 .. 10], [6 .. 15] => 1 .. 15 |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
=cut |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
sub union(@) { |
404
|
5
|
|
|
5
|
1
|
4363
|
my %set; |
405
|
|
|
|
|
|
|
|
406
|
5
|
100
|
|
|
|
9
|
do { undef @set{@$_} if @$_ } for @_; |
|
9
|
|
|
|
|
41
|
|
407
|
|
|
|
|
|
|
|
408
|
5
|
|
|
|
|
27
|
return keys %set; |
409
|
|
|
|
|
|
|
} |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=head2 union_by(&@) |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
Given a choice function and multiple set references, return a new set containing all the |
414
|
|
|
|
|
|
|
elements that exist in any set according to the choice function. |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
=cut |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
sub union_by(&@) { |
419
|
5
|
|
|
5
|
1
|
7122
|
my $func = shift; |
420
|
|
|
|
|
|
|
|
421
|
5
|
|
|
|
|
6
|
my %set; |
422
|
|
|
|
|
|
|
|
423
|
5
|
100
|
|
|
|
12
|
do { @set{ map { $func->($_) } @$_ } = @$_ if @$_ } for @_; |
|
9
|
|
|
|
|
57
|
|
|
80
|
|
|
|
|
177
|
|
424
|
|
|
|
|
|
|
|
425
|
5
|
|
|
|
|
50
|
return values %set; |
426
|
|
|
|
|
|
|
} |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
=head1 PREDICATES |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
=cut |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
=head2 is_disjoint($$) |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
Given two set references, return true if both sets contain none of the same values. |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
is_disjoint [1 .. 5], [6 .. 10] => true |
437
|
|
|
|
|
|
|
is_disjoint [1 .. 6], [4 .. 10] => false |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
=cut |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
sub is_disjoint($$) { |
442
|
8
|
|
|
8
|
1
|
1542
|
my @set = &intersection(@_[0,1]); |
443
|
8
|
|
|
|
|
34
|
return ! @set; |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=head2 is_disjoint_by(&$$) |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
Given a choice function and two sets references, return true if both sets |
449
|
|
|
|
|
|
|
contain none of the same values according to the choice function. |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=cut |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
sub is_disjoint_by(&$$) { |
454
|
8
|
|
|
8
|
1
|
1649
|
my @set = &intersection_by(@_[0,1,2]); |
455
|
8
|
|
|
|
|
29
|
return ! @set; |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
=head2 is_equal($$) |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
Given two set references, return true if both sets contain all the same values. |
461
|
|
|
|
|
|
|
Aliased by is_equivalent. |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
is_equal [1 .. 5], [1 .. 5] => true |
464
|
|
|
|
|
|
|
is_equal [1 .. 10], [6 .. 15] => false |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
=cut |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
sub is_equal($$) { |
469
|
8
|
|
|
8
|
1
|
1789
|
my @set = &intersection(@_[0,1]); |
470
|
8
|
|
100
|
|
|
8
|
return @set == @{$_[0]} && @set == @{$_[1]}; |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
*is_equivalent = \&is_equal; |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
=head2 is_equal_by(&$$) |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
Given a choice function and two sets references, return true if both sets |
477
|
|
|
|
|
|
|
contain all the same values according to the choice function. |
478
|
|
|
|
|
|
|
Aliased by is_equivalent_by. |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
=cut |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
sub is_equal_by(&$$) { |
483
|
8
|
|
|
8
|
1
|
1612
|
my @set = &intersection_by(@_[0,1,2]); |
484
|
8
|
|
100
|
|
|
7
|
return @set == @{$_[1]} && @set == @{$_[2]}; |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
*is_equivalent_by = \&is_equal_by; |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
=head2 is_pairwise_disjoint(@) |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
Given multiple set references, return true if every set is disjoint from every |
491
|
|
|
|
|
|
|
other set. |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
is_pairwise_disjoint [1 .. 5], [6 .. 10], [11 .. 15] => true |
494
|
|
|
|
|
|
|
is_pairwise_disjoint [1 .. 5], [6 .. 10], [11 .. 15], [3 .. 8] => false |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
=cut |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
sub is_pairwise_disjoint(@) { |
499
|
5
|
|
|
5
|
1
|
218
|
my @sets = &disjoint(@_); |
500
|
5
|
100
|
|
|
|
8
|
do { return 0 if @{$sets[$_]} != @{$_[$_]} } for 0 .. $#sets; |
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
14
|
|
|
12
|
|
|
|
|
30
|
|
501
|
3
|
|
|
|
|
21
|
return 1; |
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=head2 is_pairwise_disjoint_by(&@) |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
Given a choice function and multiple set references, return true if every set |
507
|
|
|
|
|
|
|
is disjoint from every other set according to the choice function. |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
=cut |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
sub is_pairwise_disjoint_by(&@) { |
512
|
5
|
|
|
5
|
1
|
10
|
my @sets = &disjoint_by((shift), @_); |
513
|
5
|
100
|
|
|
|
20
|
do { return 0 if @{$sets[$_]} != @{$_[$_]} } for 0 .. $#sets; |
|
12
|
|
|
|
|
6
|
|
|
12
|
|
|
|
|
13
|
|
|
12
|
|
|
|
|
30
|
|
514
|
3
|
|
|
|
|
10
|
return 1; |
515
|
|
|
|
|
|
|
} |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=head2 is_proper_subset($$) |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
Given two set references, return true if the first set is fully contained by |
520
|
|
|
|
|
|
|
but is not equivalent to the second. |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
is_proper_subset [1 .. 5], [1 .. 10] => true |
523
|
|
|
|
|
|
|
is_proper_subset [1 .. 5], [1 .. 5] => false |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
=cut |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
sub is_proper_subset($$) { |
528
|
8
|
|
|
8
|
1
|
1577
|
my @set = &intersection(@_[0,1]); |
529
|
8
|
|
100
|
|
|
8
|
return @set == @{$_[0]} && @set != @{$_[1]}; |
530
|
|
|
|
|
|
|
} |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=head2 is_proper_subset_by(&$$) |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
Given a choice function and two set references, return true if the first set |
535
|
|
|
|
|
|
|
is fully contained by but is not equivalent to the second according to the |
536
|
|
|
|
|
|
|
choice function. |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
=cut |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
sub is_proper_subset_by(&$$) { |
541
|
8
|
|
|
8
|
1
|
1657
|
my @set = &intersection_by(@_[0,1,2]); |
542
|
8
|
|
100
|
|
|
9
|
return @set == @{$_[1]} && @set != @{$_[2]}; |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
=head2 is_proper_superset($$) |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
Given two set references, return true if the first set fully contains but is |
548
|
|
|
|
|
|
|
not equivalent to the second. |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
is_proper_superset [1 .. 10], [1 .. 5] => true |
551
|
|
|
|
|
|
|
is_proper_superset [1 .. 5], [1 .. 5] => false |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=cut |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
sub is_proper_superset($$) { |
556
|
8
|
|
|
8
|
1
|
1700
|
my @set = &intersection(@_[0,1]); |
557
|
8
|
|
100
|
|
|
8
|
return @set != @{$_[0]} && @set == @{$_[1]}; |
558
|
|
|
|
|
|
|
} |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
=head2 is_proper_superset_by(&$$) |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
Given a choice function and two set references, return true if the first set |
563
|
|
|
|
|
|
|
fully contains but is not equivalent to the second according to the choice |
564
|
|
|
|
|
|
|
function. |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=cut |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
sub is_proper_superset_by(&$$) { |
569
|
8
|
|
|
8
|
1
|
1694
|
my @set = &intersection_by(@_[0,1,2]); |
570
|
8
|
|
100
|
|
|
8
|
return @set != @{$_[1]} && @set == @{$_[2]}; |
571
|
|
|
|
|
|
|
} |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
=head2 is_subset($$) |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
Given two set references, return true if the first set is fully contained by |
576
|
|
|
|
|
|
|
the second. |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
is_subset [1 .. 5], [1 .. 10] => true |
579
|
|
|
|
|
|
|
is_subset [1 .. 5], [1 .. 5] => true |
580
|
|
|
|
|
|
|
is_subset [1 .. 5], [2 .. 11] => false |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=cut |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
sub is_subset($$) { |
585
|
8
|
|
|
8
|
1
|
1597
|
my @set = &intersection(@_[0,1]); |
586
|
8
|
|
|
|
|
8
|
return @set == @{$_[0]}; |
|
8
|
|
|
|
|
31
|
|
587
|
|
|
|
|
|
|
} |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
=head2 is_subset_by(&$$) |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
Given a choice function and two set references, return true if the first set |
592
|
|
|
|
|
|
|
is fully contained by the second according to the choice function. |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
=cut |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
sub is_subset_by(&$$) { |
597
|
8
|
|
|
8
|
1
|
1640
|
my @set = &intersection_by(@_[0,1,2]); |
598
|
8
|
|
|
|
|
11
|
return @set == @{$_[1]}; |
|
8
|
|
|
|
|
30
|
|
599
|
|
|
|
|
|
|
} |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
=head2 is_superset($$) |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
Given two set references, return true if the first set fully contains the |
604
|
|
|
|
|
|
|
second. |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
is_superset [1 .. 10], [1 .. 5] => true |
607
|
|
|
|
|
|
|
is_superset [1 .. 5], [1 .. 5] => true |
608
|
|
|
|
|
|
|
is_subset [1 .. 5], [2 .. 11] => false |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
=cut |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
sub is_superset($$) { |
613
|
8
|
|
|
8
|
1
|
1601
|
my @set = &intersection(@_[0,1]); |
614
|
8
|
|
|
|
|
9
|
return @set == @{$_[1]}; |
|
8
|
|
|
|
|
30
|
|
615
|
|
|
|
|
|
|
} |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
=head2 is_superset_by(&$$) |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
Given a choice function and two set references, return true if the first set |
620
|
|
|
|
|
|
|
fully contains the second according to the choice function. |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
=cut |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
sub is_superset_by(&$$) { |
625
|
8
|
|
|
8
|
1
|
1618
|
my @set = &intersection_by(@_[0,1,2]); |
626
|
8
|
|
|
|
|
9
|
return @set == @{$_[2]}; |
|
8
|
|
|
|
|
31
|
|
627
|
|
|
|
|
|
|
} |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
=head1 AUTHOR |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
Aaron Cohen, C<< >> |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
Special thanks to: |
634
|
|
|
|
|
|
|
L |
635
|
|
|
|
|
|
|
L |
636
|
|
|
|
|
|
|
L |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=head1 BUGS |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
641
|
|
|
|
|
|
|
the web interface at L. I will |
642
|
|
|
|
|
|
|
be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
=head1 TODO |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=over 4 |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
=item * Add SEE ALSO section |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
=back |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
=head1 SUPPORT |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
perldoc Set::Functional |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
You can also look for information at: |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
=over 4 |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
=item * Official GitHub Repo |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
L |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
=item * GitHub's Issue Tracker (report bugs here) |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
L |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
=item * CPAN Ratings |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
L |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
=item * Official CPAN Page |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
L |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=back |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
Copyright 2011-2014 Aaron Cohen. |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
685
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
686
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=cut |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
1; # End of Set::Functional |