On 10/4/05, Juerd <[EMAIL PROTECTED]> wrote:
> What should zip do given 1..3 and 1..6?
>
> (a) 1 1 2 2 3 3 4 5 6
> (b) 1 1 2 2 3 3 undef 4 undef 5 undef 6
> (c) 1 1 2 2 3 3
> (d) fail
>
> I'd want c, mostly because of code like
>
>     for @foo Y 0... -> $foo, $i { ... }
>
> Pugs currently does b.

I think (c) is correct, precisely for this reason.  The idiom:

    for 0... Y @array -> $index, $elem {...}

Is one we're trying to create.  If it involves a pain like:

    for 0... Y @array -> $index, $elem {
        $elem // last;
    }

Then it's not going to be a popular idiom.

If you want behavior (b), SWIM:

    for 0... Y @array, undef xx Inf -> $index, $elem {
        ...
    }

If that ends up being common, we could create a syntax for it, like
postfix:<...>:

    @array...      # same as (@array, undef xx Inf)

Luke

Reply via email to