Getting exclusive elements of a set in Julia - setdiff() and setdiff!() Methods Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The setdiff() is an inbuilt function in julia which is used to returns the elements which are in first set but not in second set. Syntax: setdiff(s, itrs...) Parameters: s: Specified first set.itrs: Specified second set. Returns: It returns the elements which are in first set but not in second set. Example: Python # Julia program to illustrate # the use of setdiff() method # Getting the elements which are # in first set but not in second set. println(setdiff([1, 4, 6], [1, 3, 5])) println(setdiff([1, 2, 3, 4], [0, 1, 2, 3])) println(setdiff(Set([2, 3]), BitSet([3, 4]))) Output: setdiff!() The setdiff!() is an inbuilt function in julia which is used to remove each element of set s which are also in the specified iterable. Syntax: setdiff !(s, itrs...) Parameters: s: Specified first set.itrs: Specified iterable. Returns: It returns the remaining elements of the set s after removal. Example: Python # Julia program to illustrate # the use of setdiff!() method # Getting the remaining elements of # the set s after removal. A = Set([1, 2, 3, 4]); setdiff !(A, 1:2:3); println(A) B = Set([1, 2, 3, 4, 5, 6]); setdiff !(B, 1:3:5); println(B) Output: Set([4, 2]) Set([2, 3, 5, 6]) Comment More infoAdvertise with us Next Article Set elements at a given index of array in Julia - setindex!() Method K Kanchan_Ray Follow Improve Article Tags : Julia Similar Reads Getting first and last set of elements in Julia - front() and tail() Methods The front() is an inbuilt function in julia which is used to return a tuple consisting of all but the last component of x, where x is the specified tuple. Syntax: front(x::Tuple)::Tuple Parameters: x::Tuple: Specified tuple. Returns: It returns a tuple consisting of all but the last component of x, 2 min read Getting symmetric difference of elements of sets in Julia - symdiff() and symdiff!() Methods 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 s 2 min read Set elements at a given index of array in Julia - setindex!() Method The setindex!() is an inbuilt function in julia which is used to store values from the given array X within some subset of A as specified by inds. Syntax: setindex!(A, X, inds...) Parameters: A: Specified function.X: Specified array.inds: Specified index. Returns: It does not return any values. 1 min read Getting first element of an array in Julia - first() Method The first() is an inbuilt function in julia which is used to return the first element of the specified iterable collection. Syntax: first(coll) Parameters: coll: Specified iterable collection. Returns: It returns the first element of the specified iterable collection. Example 1: Python # Julia progr 1 min read Getting minimum elements in Julia - minimum() and minimum!() Methods The minimum() is an inbuilt function in julia which is used to return minimum elements in different scenario. Syntax: minimum(f, itr) or minimum(itr) or minimum(A::AbstractArray; dims) Parameters: f: Specified function.itr: Specified list of elements.A::AbstractArray: Specified array of different d 2 min read Getting union of sets in Julia - union() and union!() Methods The union() is an inbuilt function in julia which is used to construct the union of the specified sets. Syntax: union(s, itrs...) Parameters: s: Specified first set. itrs: Specified second set. Returns: It returns the constructed union of the specified sets. Example: Python # Julia program to illust 2 min read Like