Permutations: Difference between revisions

(Nimrod -> Nim)
Line 1,289:
2341 1342 2143 1243 3124 3214 2314
1324 2134 1234
</pre>
=={{header|Eiffel}}==
<lang Eiffel>
permute(a: ARRAY[INTEGER]; k: INTEGER)
require
ar_not_void: a.count>=1
k_valid_index: k>0
local
i,t: INTEGER
do
if k=a.count then
across a as ar loop io.put_string (ar.item.out) end
io.put_string ("%N")
else
from
i:= k
until
i> a.count
loop
t:= a[k]
a[k]:= a[i]
a[i]:= t
permute(a,k+1)
t:= a[k]
a[k]:= a[i]
a[i]:= t
i:= i+1
end
end
make
do
test:= << 2,5,1>>
permute(test, 1)
end
test: ARRAY[INTEGER]
 
end
</lang Eiffel>
{{out}}
<pre>
251
215
521
512
152
125
</pre>
 
Anonymous user