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

Re: Look-ahead arguments in for loops

Thread Previous | Thread Next
From:
Damian Conway
Date:
October 1, 2005 05:53
Subject:
Re: Look-ahead arguments in for loops
Message ID:
433E86BE.2020205@conway.org
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!??

     sub contextual (@list) {
         return [undef, @list[0...]] ¥ @list ¥ [@list[1...], undef]
     }

     for contextual( create_list_here() ) -> $last, $curr, $next {
         ...
     }

The horror!!!

;-)

Damian


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