Skip to content

Commit b1b1b40

Browse files
committed
Clarifies and summarizes unordered classes, closes #2613
1 parent 4f33364 commit b1b1b40

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

doc/Language/setbagmix.pod6

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@
44
55
=SUBTITLE Unordered collections of unique and weighted objects in Perl 6
66
7-
You might want to collect objects in a container but you do not care
8-
about the order of these objects. For such cases, Perl 6 provides the
7+
8+
In a nutshell, these classes hold, in general, unordered collections of
9+
objects. Sets only consider if these objects are present or not, bags can
10+
hold several objects of the same kind, and mixes also allow fractional (and
11+
negative) weights. The regular versions are immutable, the I<Hash> versions
12+
are mutable.
13+
14+
Let's elaborate on that. If you want to collect objects in a container but you
15+
do not care about the order of these objects, Perl 6 provides the
916
I<unordered> collection types L<Set|/type/Set>,
1017
L<SetHash|/type/SetHash>, L<Bag|/type/Bag>, L<BagHash|/type/BagHash>,
1118
L<Mix|/type/Mix>, and L<MixHash|/type/MixHash>. Being unordered, these
1219
containers can be more efficient than L<Lists|/type/List> for looking up
1320
elements or dealing with repeated items.
1421
15-
If you want to get the contained objects (elements) B<without
22+
On the other hand, if you want to get the contained objects (elements) B<without
1623
duplicates> and you only care I<whether> an element is in the collection
1724
or not, you can use a L<Set|/type/Set> or L<SetHash|/type/SetHash>. If
1825
you want to get rid of duplicates but still preserve order, take a look
@@ -33,6 +40,7 @@ The types L<Mix|/type/Mix> and L<MixHash|/type/MixHash> are similar
3340
to L<Bag|/type/Bag> and L<BagHash|/type/BagHash>, but they also
3441
allow B<fractional and negative weights>.
3542
43+
3644
=begin comment
3745
=defn Bag or BagHash
3846
Collection of distinct objects mapped to integer weights
@@ -71,7 +79,7 @@ associated weights are the 'values':
7179
7280
=head1 Set/Bag operators
7381
74-
There are several infixes devoted to performing common operations on
82+
There are several infix operators devoted to performing common operations on
7583
L<Set|/type/Set>, such as unions and set differences. Other operations
7684
include boolean checks, like whether an object is an element of a
7785
C<Set>, or whether one C<Set> is a subset of another C<Set>.

0 commit comments

Comments
 (0)