Permutations: Difference between revisions
→{{header|Quackery}}: third time lucky, I hope!
(→{{header|Quackery}}: try again, somehow I f*cked up last time.) |
(→{{header|Quackery}}: third time lucky, I hope!) |
||
Line 7,393:
<code>nested join</code> adds a nest to the end of a nest as its last item.
<lang Quackery> [ ' [ [ ] ] swap times
[ [] i rot witheach
[ dup size 1+ times
[ 2dup i^ stuff
dip rot nested join
unrot ] drop ] drop ] ] is perms ( n --> [ )
4 perms witheach [ echo cr ]</lang>
{{out}}
<pre>[ 0 1 2 3 ]
[ 1 0 2 3 ]
[ 1 2 0 3 ]
[ 1 2 3 0 ]
[ 0 2 1 3 ]
[ 2 0 1 3 ]
[ 2 1 0 3 ]
[ 2 1 3 0 ]
[ 0 2 3 1 ]
[ 2 0 3 1 ]
[ 2 3 0 1 ]
[ 2 3 1 0 ]
[ 0 1 3 2 ]
[ 1 0 3 2 ]
[ 1 3 0 2 ]
[ 1 3 2 0 ]
[ 0 3 1 2 ]
[ 3 0 1 2 ]
[ 3 1 0 2 ]
[ 3 1 2 0 ]
[ 0 3 2 1 ]
[ 3 0 2 1 ]
[ 3 2 0 1 ]
[ 3 2 1 0 ]
</pre>
=={{header|R}}==
|