On Sunday, December 21, 2014 10:36:46 PM UTC-5, Ronald L. Rivest wrote:
>
> I find the following behavior of zip extremely confusing;
> either I am misunderstanding something, or perhaps there
> is a bug in the implementation of zip(?) [I would expect
> the first and last expressions to give the same result!] :
>
>
> julia> [t for t in zip([2,3,4],[6,7,8])]
> 3-element Array{(Int64,Int64),1}:
> (2,6)
> (3,7)
> (4,8)
>
> julia> x = [2,3,4]
> 3-element Array{Int64,1}:
> 2
> 3
> 4
>
> julia> y = [6,7,8]
> 3-element Array{Int64,1}:
> 6
> 7
> 8
>
> julia> [t for t in zip(x,y)]
> 1-element Array{(Any,Any),1}:
> (4,7)
>
>
> Can anyone explain this behavior??
>
> Thanks!
>
> Cheers,
> Ron Rivest
>
Your second example seemed to work properly for me using v0.3.3 on OS X:
julia> x = [2,3,4]
3-element Array{Int64,1}:
2
3
4
julia> y = [6,7,8]
3-element Array{Int64,1}:
6
7
8
julia> [t for t in zip(x,y)]
3-element Array{(Any,Any),1}:
(2,6)
(3,7)
(4,8)
Josh