Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active May 21, 2017 14:16
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/4bcbc10b4843d64b6cb14987f766b013 to your computer and use it in GitHub Desktop.
Save dogbert17/4bcbc10b4843d64b6cb14987f766b013 to your computer and use it in GitHub Desktop.
Attempt to document Setty
=head2 method pickpairs
Defined as:
multi method pickpairs(Setty:D: --> Pair:D)
multi method pickpairs(Setty:D: $count --> Seq:D)
Returns a C<Pair> or a C<Seq> of C<Pair>s depending on the candidate of the method
being invoked. Each C<Pair> returned has an element of the invocant as its key and
<True> as its value. The elements are 'picked' without replacement. If C<*>
is passed as C<$count>, or C<$count> is greater than or equal to the number of
L<elements|#method elems> of the invocant, then all element/C<True> C<Pair>s from
the invocant are returned in a random sequence.
Note that each C<pickpairs> invocation maintains its own private state and has
no effect on subsequent C<pickpairs> invocations.
my $numbers = set (4, 2, 3);
say $numbers.pickpairs; # OUTPUT: «4 => True␤»
say $numbers.pickpairs(1); # OUTPUT: «(3 => True)␤»
say $numbers.pickpairs(*); # OUTPUT: «(2 => True 4 => True 3 => True)␤»
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment