Ricoter
Ricoter

Reputation: 763

Vectorization of different dimension

I want to get all permutations of 1:3 as strings.

julia> string.(permutations(1:3)...) # 1:3 is for the example, the real problem is larger
3-element Vector{String}:
 "112233"
 "231312"
 "323121"

However the result is "transposed" as I want

6-element Vector{String}:
 "123"
 "132"
 "213"
 "231"
 "312"
 "321"

This vector will be the input of some other (vectorized) function call F.(perms) and I want to do this efficiently. How should I do this?

Upvotes: 0

Views: 101

Answers (1)

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42214

Just do:

julia> join.(permutations(1:3),"")
6-element Vector{String}:
 "123"
 "132"
 "213"
 "231"
 "312"
 "321"

Upvotes: 2

Related Questions