develooper Front page | perl.perl6.language | Postings from October 2005

Re: Look-ahead arguments in for loops

Thread Previous | Thread Next
From:
Austin Hastings
Date:
October 1, 2005 13:22
Subject:
Re: Look-ahead arguments in for loops
Message ID:
433EF011.9080809@Yahoo.com
Damian Conway wrote:

> Austin Hastings wrote:
>
>> All of these have the same solution:
>>
>> @list = ...
>> for [undef, @list[0...]] ¥ @list ¥ [@list[1...], undef] -> $last, $curr,
>> $next {
>>   ...
>> }
>>
>> Which is all but illegible.
>
>
> Oh, no! You mean I might have to write a...subroutine!??
>

Austin Hastings wrote:

>>1. Requirement to repeat the possibly complex expression for the list.
>>2. Possible high cost of generating the list.
>>3. Possible unique nature of the list.
>>

The subroutine addresses #1, but not 2 or 3.

Also, there's a #4: modified state, which is hinted at but not really
covered by #3.

=Austin


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