Page 2 of 2

Re: Is there a better/nicer way?

Posted: Sun Mar 28, 2021 4:38 pm
by Veli-Matti
If that @ wasn't so slow...


rot_wm4←{⍺←2 ⋄ ⍺>≢⍵:⊂⍵ ⋄ ↓n r⍴(∊(-⍺),/⍵)@(,((1+r)ׯ1+⍳n)∘.+⍳⍺)⊢(r×n←1-⍺-r←≢⍵)⍴⍵}
]runtime -c "5 rot_wm4 333⍴⎕A" "5 rot_mk2 333⍴⎕A"

5 rot_wm4 333⍴⎕A → 8.6E¯5 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
5 rot_mk2 333⍴⎕A → 6.3E¯5 | -27% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕

But nevertheless, mission accomplished: seemingly there wasn't any new ingenious way to solve the initial problem (which was part of the module for finding typos in a very long list of cd tracks).

-wm

Re: Is there a better/nicer way?

Posted: Sun Mar 28, 2021 5:49 pm
by ArrayMacNB
Quick and dirty, partly due to passing a noun as ⍺⍺:

rot←{⍺←3 ⋄ ⍺{t←⍵ ⋄ (⍺⍺↑⍺⌽t)←⌽⍺⍺↑⍺⌽t ⋄ t}∘⍵¨¯1+⍳(1-⍺)+≢⍵}

Having to use a temporary for the selective assignment does itch a bit, but it works.

Re: Is there a better/nicer way?

Posted: Mon Mar 29, 2021 5:41 pm
by Phil Last
20210329_171735.jpg
Morten|Dyalog wrote:"Flat" APL rocks!