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.