Permutations by swapping: Difference between revisions

Content added Content deleted
(Add Nimrod)
Line 747:
=={{header|Nimrod}}==
<lang nimrod># iterative Boothroyd method
iterator permutations*[T](ys: openarray[T]): tuple[perm: seq[T], sign: int] =
var
d = 1
Line 772:
inc c[d]
 
if isMainModule:
for i in permutations([0,1,2]):
echo i
 
echo ""
 
for i in permutations([0,1,2,3]):
echo i</lang>
Output:
<pre>(perm: @[0, 1, 2], sign: 1)