Skip to content

Commit f0ce101

Browse files
committed
Provide documentation for List.head/tail
1 parent 90ea0cd commit f0ce101

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

doc/Type/List.pod

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,42 @@ Examples:
345345
say (1, 22/7, 42, 300).first: * > 5, :p; # 2 => 42
346346
say (1, 22/7, 42, 300).first: * > 5, :kv, :end; # 3 300
347347
348+
=head2 method head
349+
350+
Defined as:
351+
352+
multi method head(List:D: Int:D $number) returns Seq:D
353+
354+
Usage:
355+
356+
LIST.head(NUMBER)
357+
358+
Returns the B<first> NUMBER items of the list. Returns an empty list if
359+
NUMBER <= 0.
360+
361+
Examples:
362+
363+
say ^10 .head(5) # 0 1 2 3 4
364+
say ^Inf .head(5) # 0 1 2 3 4
365+
366+
=head2 method tail
367+
368+
Defined as:
369+
370+
multi method tail(List:D: Int:D $number) returns Seq:D
371+
372+
Usage:
373+
374+
LIST.tail(NUMBER)
375+
376+
Returns the B<last> NUMBER items of the list. Returns an empty list if
377+
NUMBER <= 0. Throws an exception if the list is lazy.
378+
379+
Examples:
380+
381+
say ^10 .tail(5) # 5 6 7 8 9
382+
say ^Inf .tail(5) # Cannot tail a lazy list
383+
348384
=head2 routine classify
349385
350386
Defined as:

0 commit comments

Comments
 (0)