Venus
view release on metacpan or search on metacpan
t/Venus_Range.t view on Meta::CPAN
my $select = $range->select;
# ['a'..'i']
=cut
$test->for('example', 3, 'select', sub {
my ($tryable) = @_;
my $result = $tryable->result;
is_deeply $result, ['a'..'i'];
$result
});
=example-4 select
package main;
use Venus::Range;
my $range = Venus::Range->parse(':-2', ['a'..'i']);
my $select = $range->select;
# ['a'..'h']
=cut
$test->for('example', 4, 'select', sub {
my ($tryable) = @_;
my $result = $tryable->result;
is_deeply $result, ['a'..'h'];
$result
});
=example-5 select
package main;
use Venus::Range;
my $range = Venus::Range->parse('2:8:2', ['a'..'i']);
my $select = $range->select;
# ['c', 'e', 'g', 'i']
=cut
$test->for('example', 5, 'select', sub {
my ($tryable) = @_;
my $result = $tryable->result;
is_deeply $result, ['c', 'e', 'g', 'i'];
$result
});
=method split
The split method splits the elements into two sets of elements at the index
specific and returns a tuple of two arrayrefs. The first arrayref will include
everything L<"before"|/before> the index provided, and the second tuple will
include everything L<"after"|/after> the index provided. This operation will
always exclude the element at the index the elements are split on. See
L</partition> for an inclusive split operation.
=signature split
split(number $index) (tuple[arrayref, arrayref])
=metadata split
{
since => '4.15',
}
=cut
=example-1 split
# given: synopsis
package main;
my $split = $range->split;
# [[], ['b'..'i']]
=cut
$test->for('example', 1, 'split', sub {
my ($tryable) = @_;
my $result = $tryable->result;
is_deeply $result, [[], ['b'..'i']];
$result
});
=example-2 split
# given: synopsis
package main;
my $split = $range->split(0);
# [[], ['a'..'i']]
=cut
$test->for('example', 2, 'split', sub {
my ($tryable) = @_;
my $result = $tryable->result;
is_deeply $result, [[], ['b'..'i']];
$result
});
=example-3 split
( run in 0.742 second using v1.01-cache-2.11-cpan-71847e10f99 )