An open API service indexing awesome lists of open source software.

https://github.com/preaction/list-slice

Slice-like operations on lists
https://github.com/preaction/list-slice

Last synced: about 1 year ago
JSON representation

Slice-like operations on lists

Awesome Lists containing this project

README

          

=head1 SYNOPSIS

use List::Slice qw( head tail );

=head1 DESCRIPTION

This module provides functions for slicing lists. This is helpful when you
want to do a chain of manipulations on a list (map, grep, sort) and then
slice, without the cumbersome C<(...)[x]> syntax.

=head1 FUNCTIONS

=head2 head

my @values = head $size, @list;

Returns the first C<$size> elements from C<@list>. If C<$size> is negative, returns
all but the last C<$size> elements from C<@list>.

@result = head 2, qw( foo bar baz );
# foo, bar

@result = head -2, qw( foo bar baz );
# foo

=head2 tail

my @values = tail $size, @list;

Returns the last C<$size> elements from C<@list>. If C<$size> is negative, returns
all but the first C<$size> elements from C<@list>.

@result = tail 2, qw( foo bar baz );
# bar, baz

@result = tail -2, qw( foo bar baz );
# baz

=head1 SEE ALSO

L, L, L