Juerd 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 agree that C<zip> should have named options (perhaps :min and :max) that
allow precise behaviour to be specified.
I suspect that the dwimmiest default would be for C<zip> to stop zipping at
the length of the shortest finite argument. And to fail unless all finite
arguments are of the same length. Hence:
@i3 = 1..3 ;
@a3 = 'a'..'c' ;
@i6 = 1..6 ;
zip(@a3, @i3) # 'a', 1, 'b', 2, 'c', 3
zip(@i3, @i6) # fail
zip(100..., @a3, @i3) # 100, 'a', 1, 101, 'b', 2, 102, 'c', 3
zip(100..., @a3, @i6) # fail
Damian