We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
nthperm!(a, k)
1 parent 911e70f commit d933e95Copy full SHA for d933e95
src/permutations.jl
@@ -263,6 +263,36 @@ end
263
264
265
In-place version of [`nthperm`](@ref); the array `a` is overwritten.
266
+
267
+# Examples
268
+```jldoctest
269
+julia> a = [1, 2, 3];
270
271
+julia> collect(permutations(a))
272
+6-element Vector{Vector{Int64}}:
273
+ [1, 2, 3]
274
+ [1, 3, 2]
275
+ [2, 1, 3]
276
+ [2, 3, 1]
277
+ [3, 1, 2]
278
+ [3, 2, 1]
279
280
+julia> nthperm!(a, 3); a
281
+3-element Vector{Int64}:
282
+ 2
283
+ 1
284
+ 3
285
286
+julia> nthperm!(a, 4); a
287
288
289
290
291
292
+julia> nthperm!(a, 0)
293
+ERROR: ArgumentError: permutation k must satisfy 0 < k ≤ 6, got 0
294
+[...]
295
+```
296
"""
297
function nthperm!(a::AbstractVector, k::Integer)
298
n = length(a)
0 commit comments