develooper Front page | perl.perl5.porters | Postings from July 2013

Re: [perl #118089] Feature: list slices to the end

Thread Previous | Thread Next
From:
Dr.Ruud
Date:
July 7, 2013 06:52
Subject:
Re: [perl #118089] Feature: list slices to the end
Message ID:
20130707065153.22163.qmail@lists-nntp.develooper.com
On 21/05/2013 16:15, Ed Avis wrote:

> Sometimes you want to slice a list from some index to the end.
> [...] It would be handy to have a syntax for slicing to
> the end of a list, like this:
>
>      my @end_part = @a[ 1 .. ];
>
> Here only the left part of the '..' is given and the end of the
> slice is implicitly the end of the list.  For symmetry, it would
> also be useful to have
>
>      my @start_part = @a[ .. 5 ];

Or support negative indexes inside slicers:

   my @end_part = @a[ 1 .. _(-1) ];

(the _() to express topical run time action)


Or a topical $# alias, like $_#.

   my @end_part = @a[ 1 .. $_# ];

-- 
Ruud



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About