Permutations: Difference between revisions

m (→‎{{header|Wren}}: Minor tidy)
Line 5,691:
This follows the Go language non-recursive example, but is not limited to integers, or even to numbers.
 
{{works with|langur|0.1013.5}}
Prior to 0.10, multi-variable declaration/assignment would use parentheses around variable names and values. 0.10 also parses the increment section of a for loop as a multi-variable assignment, not as a list of assignments.
 
<syntaxhighlight lang="langur">val .factorial = f if(.x < 2: 1; .x x self(.x - 1))
 
val .permute = f(.arrlist) {
if not isArrayisList(.arrlist): throw "expected arraylist"
 
val .limit = 10
if len(.arrlist) > .limit: throw $"permutation limit exceeded (currently \.limit;)"
 
var .elements = .arrlist
var .ordinals = pseries len .elements
 
Line 5,708 ⟶ 5,706:
var .i, .j
 
for[.p=[.arrlist]] of .factorial(len .arrlist)-1 {
.i = .n - 1
.j = .n
889

edits