tail#

Return the last $size elements of a list.

Σύνοψη#

my @last = tail $size, @list;
my @last = tail 2, qw( foo bar baz );    # ('bar', 'baz')

Τι επιστρέφεται#

A list of at most $size elements, taken from the end of the input. If $size is negative, tail returns all but the first -$size elements - useful for dropping a head.

Παραδείγματα#

my @r = tail  2, qw( foo bar baz );   # ('bar', 'baz')
my @r = tail -2, qw( foo bar baz );   # ('baz')
my @r = tail  5, qw( a b c );         # ('a', 'b', 'c') - fewer than $size

Διαφορές από το upstream#

Fully compatible with upstream.

Δείτε επίσης#

  • head - mirror operation, taking from the start.

  • sample - random selection without positional bias.