julia> a = [1,2,3]
3-element Vector{Int64}:
1
2
3
julia> b = [3,4,4,5,6]
5-element Vector{Int64}:
3
4
4
5
6
julia> symdiff(a,b)
4-element Vector{Int64}:
1
2
5
6
I would expect the result to be 1,2,4,5,6
.
if a,b
are sets the result is correct
julia> symdiff(Set(a),Set(b))
Set{Int64} with 5 elements:
5
4
6
2
1
Going one level down in the call stack:
julia> symdiff!(Int[], [1, 2, 3], [3, 4, 5, 6])
5-element Vector{Int64}:
1
2
4
5
6
julia> symdiff!(Int[], [1, 2, 3], [3, 4, 4, 5, 6])
4-element Vector{Int64}:
1
2
5
6
And one more (ref. https://github.com/JuliaLang/julia/blob/master/base/array.jl#L2666-L2667):
julia> symdiff!(Set{Int}(), Int[], [1, 2, 3], [3, 4, 5, 6])
Set{Int64} with 5 elements:
5
4
6
2
1
julia> symdiff!(Set{Int}(), Int[], [1, 2, 3], [3, 4, 4, 5, 6])
Set{Int64} with 4 elements:
5
6
2
1
thanks! seems like it should call union(setdiff(a,b),setdiff(b,a))
or call symdiff!
with the larger vector first
I opened an issue here: https://github.com/JuliaLang/julia/issues/44591
Great, will post my findings on the issue then.
thank you!
Last updated: Nov 22 2024 at 04:41 UTC