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 perfectly clear:

    map { "Element $^array_index is called $^array_value" } <== @array.kv;

Likewise, for your original formulation:

    for @array {
        say "$^index\t$^value";
    }


Given that we already have both placeholders (above) and pointy blocks:

    for @array -> $index, $value {
        say "$index\t$value";
    }

to achieve this task, and given that both mechanisms allow you to choose the name of the counter variable (rather than being stuck with some unreadable punctuation variable), I don't think we need a third mechanism for this.

Damian

Reply via email to