Related Articles

Related Articles

Getting symmetric difference of elements of sets in Julia – symdiff() and symdiff!() Methods
  • Last Updated : 01 Apr, 2020

The symdiff() is an inbuilt function in julia which is used to construct the symmetric difference of elements in the passed in sets.

Syntax: symdiff(s, itrs…)

Parameters:

  • s: Specified first set.
  • itrs: Specified second set.

Returns: It returns the symmetric difference of elements in the passed in sets.

Example:



filter_none

edit
close

play_arrow

link
brightness_4
code

# Julia program to illustrate 
# the use of symdiff() method
   
# Getting the symmetric difference of
# elements in the passed in sets. 
println(symdiff([1, 4, 6], [1, 3, 5]))
println(symdiff([1, 2, 3, 4], [0, 1, 2, 3]))
println(symdiff(unique([1, 2, 1]), unique([2, 1, 2])))

chevron_right


Output:

[4, 6, 3, 5]
[4, 0]
Int64[]

symdiff!()

The symdiff!() is an inbuilt function in julia which is used to construct the symmetric difference of the passed in sets, and overwrite the spcified set s with the result.

Syntax:
symdiff!(s::Union{AbstractSet, AbstractVector}, itrs…)

Parameters:

  • s: Specified set.
  • itrs: Specified iterable.

Returns: It returns the symmetric difference of the passed in sets.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Julia program to illustrate 
# the use of symdiff !() method
   
# Getting the symmetric difference of
# elements in the passed in sets and 
# overwrite s with the result
println(symdiff !([1, 4, 6], 1:2))
println(symdiff !([1, 2, 3, 4], [0, 1, 2, 3]))
println(symdiff !(unique([1, 2, 1]), unique([2, 1, 2])))

chevron_right


Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :