Damian Conway schreef:
> [for @array -> $index, $value {...}]
>
> No. There's no such magic. I simply screwed up. I should have written:
> for @array.kv -> $index, $value {...}
> :-(
Ah, much clearer now.
--
Affijn, Ruud
"Gewoon is een tijger."
Damian (>), Ruud (>>), Damian (>>>), Carl ():
> >> But it can hardly be blamed for clarity.
> >
> > That's a little unfair.
>
> "can hardly be blamed" -> "can easily be praised"
Apologies to Carl if I misinterpreted. I read it as:
"can hardly be blamed for (having) clarity"
;-)
No,
for @array -> $index, $value
{
say "Element $_ is called $value"
}
But I don't understand how the "$index, $value" pair gets its values; is
@array somehow turned into a hash with the index as the key?
With @array -> $index, $value {}, is $_ an alias of $index?
No. There's no
"Damian Conway" schreef:
> Ruud:
>> Damian:
>>> Carl:
But it can hardly be blamed for clarity.
>>>
>>> That's a little unfair.
>>
>> "can hardly be blamed" -> "can easily be praised"
>
> Apologies to Carl if I misinterpreted. I read it as:
> "can hardly be blamed for (having) clarity"
>
>> But it can hardly be blamed for clarity.
>
> That's a little unfair.
"can hardly be blamed" -> "can easily be praised"
Apologies to Carl if I misinterpreted. I read it as:
"can hardly be blamed for (having) clarity"
;-)
Damian
Damian Conway schreef:
> [attribution repaired] Carl:
>> But it can hardly be blamed for clarity.
>
> That's a little unfair.
"can hardly be blamed" -> "can easily be praised"
--
Affijn, Ruud
"Gewoon is een tijger."
pugs> map { "Element $^a is called $^b" }: @array.kv;
("Element 0 is called london",
"Element 1 is called bridge",
"Element 2 is called is",
"Element 3 is called falling",
"Element 4 is called down")
But it can hardly be blamed for clarity.
That's a little unfair. Choose good names and it's per
Having read this thread, I tend to think you're insane for bringing it
up again :-)
That said, I'll entertain the discussion for a bit ...
On Tue, Aug 29, 2006 at 08:33:20AM +0200, Carl Mäsak wrote:
> Questions:
>
> - Is the itch big enough for this? The more I look at the first piece
> of cod
Carl Mäsak schreef:
> I suppose doing a map or a grep over @array.kv is possible:
>
> pugs> my @array =
> ("london", "bridge", "is", "falling", "down")
>
> pugs> map { "Element $^a is called $^b" }: @array.kv;
> ("Element 0 is called london",
> "Element 1 is called bridge",
> "Element 2 is call
Mark (>), Carl (>>):
> Hey do you know what would be cool in perl 6
> A special variable for when you do a for (@array) style loop
> it would always have the index of the array
>
> Discussed on #perl6: it's already quite easy in Perl 6 to loop with an
> explicit index:
>
> my @array = ;
> for
"Carl Mäsak" schreef:
> Ruud:
>> Carl:
>>> But maybe a variable that implicitly carries along the loop index
>>> would be even snazzier?
>>>
>>> for @array -> $val {
>>> say "$.\t$val";
>>> }
>>
>> Or give the block a name (label), and have an index (or several
>> indexes, like some that are res
Carl Mäsak wrote:
Hey do you know what would be cool in perl 6
A special variable for when you do a for (@array) style loop
it would always have the index of the array
Discussed on #perl6: it's already quite easy in Perl 6 to loop with an
explicit index:
my @array = ;
for @array.kv -> $i, $v
Ruud (>), Carl (>>):
> But maybe a variable that implicitly carries along the loop index
> would be even snazzier?
>
> for @array -> $val {
> say "$.\t$val";
> }
Or give the block a name (label), and have an index (or several indexes, like
some that are reset by redo an some that are not) avai
Carl Mäsak wrote:
> But maybe a variable that implicitly carries along the loop index
> would be even snazzier?
>
> for @array -> $val {
> say "$.\t$val";
> }
Or give the block a name (label), and have an index (or several indexes, like
some that are reset by redo an some that are not) availabl
Hey do you know what would be cool in perl 6
A special variable for when you do a for (@array) style loop
it would always have the index of the array
Discussed on #perl6: it's already quite easy in Perl 6 to loop with an
explicit index:
my @array = ;
for @array.kv -> $i, $val {
say "$i\t$val
15 matches
Mail list logo