Permutations: Difference between revisions

Frink
(add APL implementation)
(Frink)
Line 3,487:
<pre>1234 2134 3124 1324 2314 3214 4213 2413 1423 4123 2143 1243
1342 3142 4132 1432 3412 4312 4321 3421 2431 4231 3241 2341</pre>
 
=={{header|Frink}}==
Frink's array class has built-in methods <CODE>permute[]</CODE> and <CODE>lexicographicPermute[]</CODE> which permute the elements of an array in reflected Gray code order and lexicographic order respectively.
<lang frink>a = [1,2,3,4]
formatTable[a.lexicographicPermute[]]</lang>
 
{{out}}
<pre>1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1
</pre>
 
=={{header|GAP}}==
494

edits