RosettaCodeData/Task/Permutations-by-swapping/Quackery/permutations-by-swapping.quackery
2023-07-01 13:44:08 -04:00

35 lines
780 B
Text

[ stack ] is parity ( --> s )
[ 1 & ] is odd ( n --> b )
[ [] swap witheach
[ nested
i odd 2 * 1 -
join nested join ] ] is +signs ( [ --> [ )
[ dup
[ dup 0 = iff
[ drop ' [ [ ] ] ]
done
dup temp put
1 - recurse
[] swap
witheach
[ i odd parity put
temp share times
[ temp share 1 -
over
parity share
iff i else i^
stuff
nested rot join
swap ]
drop
parity release ]
temp release ]
swap odd if reverse
+signs ] is perms ( n --> [ )
3 perms witheach [ echo cr ]
cr
4 perms witheach [ echo cr ]