not sure I have fully understood the argument on the functioning of collect in relation to the determination of the types of the elements making up the vector.
I try to submit two other examples that if clarified I can allow myself to better understand how things are going.
functions derive this discussion
Here the compréhension completely determines the type of the components the dict
julia> [ (p,pp...)=>pv(p,pp) for(p,pp) in Iterators.flatten([k.=>v for (k,v) in d1])]
7-element Vector{Pair{Tuple{Char, Int64, Int64}, Float64}}:
('p', 1, 2) => 2.5
('p', 1, 7) => 4.1
('p', 2, 3) => 7.4
('q', 1, 2) => 2.5
('q', 2, 3) => 7.4
('q', 2, 5) => 5.6
('q', 5, 2) => 3.2
here not
ulia> [ (person,pair...)=>pv(person,pair) for (person,pair) in
Iterators.product(Persons,Pairs)][:]
18-element Vector{Pair{Tuple{Char, Int64, Int64}}}:
('p', 1, 2) => 2.5
('q', 1, 2) => 2.5
('p', 1, 7) => 4.1
('q', 1, 7) => nothing
('p', 2, 3) => 7.4
('q', 2, 3) => 7.4
('p', 2, 5) => nothing
('q', 2, 5) => 5.6
('p', 3, 4) => nothing
('q', 3, 4) => nothing
('p', 3, 5) => nothing
('q', 3, 5) => nothing
('p', 4, 1) => nothing
('q', 4, 1) => nothing
('p', 4, 5) => nothing
('q', 4, 5) => nothing
('p', 5, 2) => nothing
('q', 5, 2) => 3.2
but if I define the dictionary by hand, I get
julia> Dict(
('p', 1, 2) => 2.5,
('q', 1, 2) => 2.5,
('p', 1, 7) => 4.1,
('q', 1, 7) => nothing,
('p', 2, 3) => 7.4,
)
Dict{Tuple{Char, Int64, Int64}, Union{Nothing, Float64}} with 5 entries:
('p', 1, 7) => 4.1
('q', 1, 7) => nothing
('p', 2, 3) => 7.4
('p', 1, 2) => 2.5
('q', 1, 2) => 2.5