Skip to content

Commit

Permalink
Rewrites examples and changes def of head, refs #2631
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Feb 23, 2019
1 parent e96b81b commit 0e2a128
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions doc/Type/List.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,19 @@ L«C<head>|/routine/head» and L«C<tail>|/routine/tail» methods.
Defined as:
method head(List:D: Int(Cool) $number = 1 --> Seq:D)
multi method head(Any:D:) is raw
multi method head(Any:D: Callable:D $w)
multi method head(Any:D: $n)
Returns the B<first> NUMBER items of the list. Returns an empty list if
NUMBER <= 0. Defaults to the first element seen if no NUMBER specified.
This method is directly inherited from L<Any>, and it returns the B<first> C<$n>
items of the list, an empty list if C<$n> <= 0, or the first element seen with
no argument. The version that takes a Callable is used to use a C<WhateverCode> to specify all elements, starting from the first, but the last ones.
Examples:
say ^10 .head(5); # OUTPUT: «(0 1 2 3 4)␤»
say ^∞ .head(5); # OUTPUT: «(0 1 2 3 4)␤»
say ^10 .head; # OUTPUT: «0␤»
say ^∞ .head; # OUTPUT: «0␤»
say <a b c d e>.head ; # OUTPUT: «a␤»
say <a b c d e>.head(2); # OUTPUT: «(a b)␤»
say <a b c d e>.head(*-3); # OUTPUT: «(a b)␤»
=head2 method tail
Expand Down

0 comments on commit 0e2a128

Please sign in to comment.