# Selecting the Set from an Array of integers

**URL:** <https://discourse.julialang.org/t/selecting-the-set-from-an-array-of-integers/32050>\
**Category:** General Usage\
**Created:** [December 9, 2019, 2:56pm UTC](https://discourse.julialang.org/t/selecting-the-set-from-an-array-of-integers/32050 "2019-12-09T14:56:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/diger/32/36786_2.png) [@Diger](https://discourse.julialang.org/u/Diger)\
**Post date:** [December 9, 2019, 2:56pm UTC](https://discourse.julialang.org/t/selecting-the-set-from-an-array-of-integers/32050/1 "2019-12-09T14:56:49Z")

</div>

I have the Array  
A=[0,0,0,2,1,0,1,3,2,3,4,5,1,7,1]  
for which the Set is  
S=[0,1,2,3,4,5,7]

Set(A) doesn’t work in that I get an object Set([…]), but the resulting thing should still be an Array as before. How do I do this?

---

<div class="post-metadata">

**Author:** ![kdyrhage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdyrhage/32/2326_2.png) [@kdyrhage](https://discourse.julialang.org/u/kdyrhage)\
**Post date:** [December 9, 2019, 3:08pm UTC](https://discourse.julialang.org/t/selecting-the-set-from-an-array-of-integers/32050/2 "2019-12-09T15:08:38Z")

</div>

```julia
julia> A=[0,0,0,2,1,0,1,3,2,3,4,5,1,7,1];

julia> unique(A)
7-element Array{Int64,1}:
 0
 2
 1
 3
 4
 5
 7

```

---

<div class="post-metadata">

**Author:** ![Karajan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/karajan/32/8545_2.png) [@Karajan](https://discourse.julialang.org/u/Karajan)\
**Post date:** [December 9, 2019, 3:24pm UTC](https://discourse.julialang.org/t/selecting-the-set-from-an-array-of-integers/32050/3 "2019-12-09T15:24:46Z")

</div>

For cases where it doesn’t work out as neatly, here an uglier but maybe more universal method:

```julia
julia> Set([1, 1, 2, 3])
Set([2, 3, 1])

julia> Set([1, 1, 2, 3]) |> collect
3-element Array{Int64,1}:
 2
 3
 1

```
