develooper Front page | perl.perl6.language | Postings from September 2001

RE: LangSpec: Statements and Blocks [first,last]

Thread Previous | Thread Next
From:
Sterin, Ilya
Date:
September 2, 2001 13:11
Subject:
RE: LangSpec: Statements and Blocks [first,last]
Message ID:
JNEKKMEFOONJHHJBIMEDIEIKCGAA.isterin@ciber.com


> -----Original Message-----
> From: raptor [mailto:raptor@unacs.bg]
> Sent: Sunday, September 02, 2001 1:47 PM
> To: bwarnock@capita.com
> Cc: perl6-language@perl.org
> Subject: Re: LangSpec: Statements and Blocks [first,last]
>
>
> hi,
>
> As we read in Damian Conway- Perl6-notes, there will by a
> var-iterator that
> can be used to see how many times the cycle has been "traversed" i.e.
>
> foreach my $el (@ary) {
>    .. do something ....
>      print $#;  <--- print the index (or print $i )
> }
>
> shall we have :
>
> foreach my $el (@ary) {
>      print $# if $#.first();  <--- print the index on the first iteration

I personally don't like the .first() .last() method implementation, this
means we'll have .second .third, etc...  Why not just check the var iterator
$# == 0, means the first iteration, or have a special var that is not set to
the index, but rather the iteration number 1..end, in case the there is a
way to start iteration at different points.

Ilya


> i.e. 1
>    .. do something ....
>      print $# if $#.last();  <--- print the index on the first iteration
> i.e. $#ary
> };
>
> note : we can iterate on something else not only array
> OR :
>
> foreach my $el (@ary) {
>      print $# if first;
>    .. do something ....
>      print $# if latest;
> };
>
>
> =====
> iVAN
> raptor@unacs.bg
> =====
> PS. One place where TT is before Perl :")
>

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