symdiff
symdiff(s1,s2...)
Construct the symmetric difference of elements in the passed in sets or arrays. Maintains order with arrays.
Examples
julia> s1 = Set("Hello");
julia> s2 = Set("World");
julia> symdiff(s1,s2)
Set{Char}({'d','e','H','r','W'})
julia> symdiff(sin(10), 1, 0:20)
21-element Array{Float64,1}:
-0.544021
0.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
11.0
12.0
13.0
14.0
15.0
16.0
17.0
18.0
19.0
20.0
# Set example
julia> set1 = Set([1, 2, 3, 4])
Set{Int64} with 4 elements:
4
2
3
1
julia> set2 = Set([3, 4, 5, 6])
Set{Int64} with 4 elements:
4
5
6
3
julia> symdiff(set1, set2)
Set{Int64} with 3 elements:
2
1
5
# Array example
julia> arr1 = [1, 2, 3, 4]
4-element Array{Int64,1}:
1
2
3
4
julia> arr2 = [3, 4, 5, 6]
4-element Array{Int64,1}:
3
4
5
6
julia> symdiff(arr1, arr2)
4-element Array{Int64,1}:
1
2
5
6
The symdiff
function takes in multiple sets or arrays and returns the symmetric difference of their elements. The symmetric difference is the set of elements that are present in one of the sets or arrays but not in both. The order of elements is maintained when using arrays.
Note that symdiff
works with both sets and arrays, providing flexibility in its usage.
See Also
complement, complement!, intersect, intersect!, issubset, selectperm, selectperm!, Set, setdiff, setdiff!, symdiff, union, union!,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.