pmat←{⎕ML←0             ⍝ Permutation matrix of ⍳⍵.
    {                   ⍝ perms of ⍳⍵:
        1≥⍴⍵:↑,↓⍵       ⍝ short vector: done.
        ↑⍪/⍵,∘∇¨⍵∘~¨⍵   ⍝ items prefix sub-perms of remainder.
    }⍳⍵                 ⍝ permutations of identity perm.
}

test script

Back to: notes

Back to: Workspaces

Trouble seeing APL font?