develooper Front page | perl.perl5.porters | Postings from January 2014

Re: Range idea

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
January 23, 2014 17:14
Subject:
Re: Range idea
Message ID:
CAHhgV8juiLr-sTGuxk21i6Q9Qa-XQuW-rXNnhkqe4jRND3HD5w@mail.gmail.com
On Thu, Jan 23, 2014 at 1:25 PM, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:

> Wanting to take all the elements from a list starting at position x to
> the end is pretty hard when the list is dynamic, so $#list cannot be
> used, nor can index -1
>
> Why cannot we use open range operators in this case?
>
> Both [n ..] and [n ...] are currently syntax errors
>
> $ perl -wE'say for [qw( a b c d )]->[2 ..]'
> syntax error at -e line 1, near "..]"
> Execution of -e aborted due to compilation errors.
> $ perl -wE'say for [qw( a b c d )]->[2 ...]'
> syntax error at -e line 1, near "...]"
> Execution of -e aborted due to compilation errors.
>
> either of the above could be defined to return qw(c d)


What we really want for that is lazy lists, which is not something we're
close to implementing.

Leon

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