Getting intersection of sets in Julia – intersect() and intersect!() Methods
The intersect() is an inbuilt function in julia which is used to construct the intersection of the specified sets.
Syntax:
intersect(s, itrs...)
Parameters:
- s: Specified first set.
- itrs: Specified second set.
Returns: It returns the constructed intersection of the specified sets.
Example:
Python
println(intersect([ 1 , 4 , 6 ], [ 1 , 3 , 5 ]))
println(intersect([ 1 , 2 , 3 , 4 ], [ 0 , 1 , 2 , 3 ]))
println(intersect( Set ([ 2 , 3 ]), BitSet([ 3 , 4 ])))
|
Output:
intersect!()
The intersect!() is an inbuilt function in julia which is used to intersect all passed in sets and overwrite s with the result.
Syntax:
intersect!(s::Union{AbstractSet, AbstractVector}, itrs...)
Parameters:
- s: Specified set.
- itrs: Specified iterator.
Returns: It returns the elements which intersect all passed in sets.
Example:
Python
println(intersect !([ 1 , 4 , 6 ], [ 1 , 3 , 5 ]))
println(intersect !([ 1 , 2 , 3 , 4 ], [ 0 , 1 , 2 , 3 ]))
println(intersect !( Set ([ 2 , 3 ]), BitSet([ 3 , 4 ])))
|
Output:
Last Updated :
24 Feb, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...