Skip to content

Commit 60a2343

Browse files
ararslanandreasnoack
authored andcommitted
Allow immutable collections in nthperm (#64)
1 parent efa9d0a commit 60a2343

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/permutations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ end
172172
173173
Compute the `k`th lexicographic permutation of the vector `a`.
174174
"""
175-
nthperm(a::AbstractVector, k::Integer) = nthperm!(copy(a), k)
175+
nthperm(a::AbstractVector, k::Integer) = nthperm!(collect(a), k)
176176

177177
"""
178178
nthperm(p)

test/permutations.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ end
4444

4545
@test nthperm([0,1,2],3) == [1,0,2]
4646

47+
# Immutable AbstractArrays
48+
@test nthperm(1:5, 1) == [1,2,3,4,5]
49+
4750
@test_throws ArgumentError parity([0])
4851
@test_throws ArgumentError parity([1,2,3,3])
4952
@test levicivita([1,1,2,3]) == 0

0 commit comments

Comments
 (0)