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
- Host: GitHub
- URL: https://github.com/preaction/list-slice
- Owner: preaction
- License: other
- Created: 2015-05-16T03:45:20.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-11-12T04:07:02.000Z (over 9 years ago)
- Last Synced: 2024-04-17T21:17:01.880Z (about 2 years ago)
- Language: C++
- Size: 69.3 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: CHANGES
- Contributing: CONTRIBUTING.md
- License: LICENSE
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