Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/818b4229a000c9e19c25b3c782951b44 to your computer and use it in GitHub Desktop.
Save dogbert17/818b4229a000c9e19c25b3c782951b44 to your computer and use it in GitHub Desktop.
Attempt to document Baggy.invert
=head2 method invert
Defined as:
method invert(Baggy:D:) returns Seq:D
Returns all elements and their respective weights as a L<Seq|/type/Seq> of L<Pairs|/type/Pair>,
where the element itself is the value and the weight of that element is the key, i.e.
the opposite of method L<pairs|#method pairs>. Except for some esoteric cases C<invert> on a
Baggy type returns the same result as L<antipairs|#method_antipairs>.
my $breakfast = bag <bacon eggs bacon>;
my $seq = $breakfast.invert;
say $seq.sort; # (1 => eggs 2 => bacon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment