Why the array comprehension behaves differently with the AbstractTrees.Leaves
iterator?
In the following replacing Leaves(t)
with say, range(1,3,3)
, I do get the 2D array.
julia> using AbstractTrees
julia> t = [[1, 2], 3]
2-element Vector{Any}:
[1, 2]
3
julia> [(i,j) for i in Leaves(t), j in Leaves(t) ]
9-element Vector{Tuple{Int64, Int64}}:
(1, 1)
(2, 1)
(3, 1)
(1, 2)
(2, 2)
(3, 2)
(1, 3)
(2, 3)
(3, 3)
julia> [(i,j) for i in collect(Leaves(t)), j in collect(Leaves(t)) ]
3×3 Matrix{Tuple{Int64, Int64}}:
(1, 1) (1, 2) (1, 3)
(2, 1) (2, 2) (2, 3)
(3, 1) (3, 2) (3, 3)