El jueves, 19 de noviembre de 2015, 14:45:41 (UTC-6), Ratan Sur escribió:
>
> I want to get all the unique permutations of an array of a certain length 
> and this is the only way I currently know how to do it in one line. Is 
> there a builtin function for this?
>
> julia> unique(collect(permutations([1;0;0;0;1])))
> 10-element Array{Array{Int64,1},1}:
>  [1,0,0,0,1]
>  [1,0,0,1,0]
>  [1,0,1,0,0]
>  [1,1,0,0,0]
>  [0,1,0,0,1]
>  [0,1,0,1,0]
>  [0,1,1,0,0]
>  [0,0,1,0,1]
>  [0,0,1,1,0]
>  [0,0,0,1,1]
>
>
It turns out that the following works:

unique(permutations([1, 0, 0, 0, 1]))

 

Reply via email to