)clear
∇z←permute s
→((⍴,s)≤1)/ident
→((⍴s)>2)/recurse
z←s⍪1 2⍴⌽s ⋄ →0
ident: z←s ⋄ →0
recurse: z←(((⍴,z)÷⍴s),⍴s)⍴,z←{⍵,permute s~⍵}⍤0 s
∇
⍝ Now do this
v ← {⊂ 3 3 ⍴ ⍵}⍤1 permute ⍳9
⍴v
362880
⍝ "v" is a vector of all possibles permutations of 9 numbers arranged in
a 3x3 matrix.
⍝ first 10 of the 362880 ones ...
8⎕cr ¨ 10 ↑ v
┌→────┐ ┌→────┐ ┌→────┐ ┌→────┐ ┌→────┐ ┌→────┐ ┌→────┐ ┌→────┐
┌→────┐ ┌→────┐
↓1 2 3│ ↓1 2 3│ ↓1 2 3│ ↓1 2 3│ ↓1 2 3│ ↓1 2 3│ ↓1 2 3│ ↓1 2 3│ ↓1 2
3│ ↓1 2 3│
│4 5 6│ │4 5 6│ │4 5 6│ │4 5 6│ │4 5 6│ │4 5 6│ │4 5 7│ │4 5 7│ │4 5
7│ │4 5 7│
│7 8 9│ │7 9 8│ │8 7 9│ │8 9 7│ │9 7 8│ │9 8 7│ │6 8 9│ │6 9 8│ │8 6
9│ │8 9 6│
└─────┘ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘
└─────┘ └─────┘
⍝ Now wallclock time how long it take to do a )save ... (on my fast
machine, took 139 seconds)
⍝ Remark that the )load will take something like only 1/100th or 2/100th
of the )save time.
So, ")save" is far too slow on workspace with a large number of cells ...
Hoping you can improve it (as you did for Unique few weeks ago).
Xtian.
ps: ")dump" is very fast (~2 seconds) but reloading that .apl file take near
infinite time.