Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use set operations in julia language

Tags:

julia

I want to use set() as in python in Julia. Is it possible to do so? If yes, please provide an example using the following python code

set(A) - set(B)
like image 485
Abhishek Thakur Avatar asked Dec 15 '22 21:12

Abhishek Thakur


1 Answers

The relevant functionality is explained in the docs. While you can still use -, it's been deprecated:

julia> A = [1,2,3]; B = [2,3,4];

julia> Set(A) - Set(B)
WARNING: a::Set - b::Set is deprecated, use setdiff(a,b) instead.
 in - at deprecated.jl:26
Set{Int32}({1})

julia> setdiff(A, B)
1-element Array{Int32,1}:
 1

julia> setdiff(Set(A), Set(B))
Set{Int32}({1})

Note that we can use setlike ops on arrays directly, in which case they're order-preserving.

like image 113
DSM Avatar answered Dec 21 '22 09:12

DSM