RosettaCodeData/Task/Permutations/APL/permutations.apl

8 lines
344 B
APL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

⍝ 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 ]}