Skip Menu |
 

This queue is for tickets about the Scalar-List-Utils CPAN distribution.

Report information
The Basics
Id: 124500
Status: new
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Wishlist: first_index, rfirst(_index), final(_index)
Download (untitled) / with headers
text/plain 1.2k
Extend the family of functions around 'first', to include: * first_index my $index = first_index { COND } LIST returns the first index of LIST for which COND is true; thus satisfying first { COND } LIST === LIST[ first_index { COND } LIST ] (analogous to List::MoreUtils::firstidx but named a little clearer) * rfirst / rfirst_index my $item = rfirst { COND } LIST my $index = rfirst_index { COND } LIST returns rightmost item or index of LIST for which COND is true, when scanned decrementally from the rightmost element first. This latter fact is important in the case of stateful condition functions. rfirst { COND } LIST === LIST[ rfirst_index { COND } LIST ] rfirst { COND } LIST === first { COND } reverse LIST rfirst_index { COND } LIST doesn't have a neat form using first_index on reverse LIST except when the length of the list is known. Optionally, for completeness: * final / final_index my $item = final { COND } LIST my $index = final_index { COND } LIST Returns the item or index of LIST for which COND is true for the final time when scanned incrementally, left to right. This might matter if COND is stateful in some way, such that a different answer is achieved in this scanning order. -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.