RosettaCodeData/Task/Permutations/APL/permutations.apl

8 lines
344 B
APL
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
⍝ Builtin version, takes a vector:
⎕CY'dfns'
perms{[pmat ]} ⍝ pmat always gives lexicographically ordered permutations.
⍝ Recursive fast implementation, courtesy of dzaima from The APL Orchard:
dpmat{1=:,,0 (,/)¨()¨((!-1)-1),-1}
perms2{[1+dpmat ]}