Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Created June 27, 2016 15:17
Show Gist options
  • Save dogbert17/f3ebc0f42320f2998eff513466f12bc6 to your computer and use it in GitHub Desktop.
Save dogbert17/f3ebc0f42320f2998eff513466f12bc6 to your computer and use it in GitHub Desktop.
=head2 method minmax
Defined as:
multi method minmax(Range:D:) returns List:D
If the C<Range> is an integer range (as indicated by L<is-int>), then this
method returns a list with the first and last value it will iterate over
(taking into account L<excludes-min> and L<excludes-max>). If the range is
not an integer range, the method will return a two element list containing
the start and end point of the range unless either of L<excludes-min> or
L<excludes-max> are C<True> in which case a L<Failure|/type/Failure> is returned.
say (1..5).minmax; # (1 5)
say (1^..5).minmax; # (2 5)
say (1.1..5.2).minmax; # (1.1 5.2)
say (1.1..^5.2).minmax; # Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment