Is there a better/nicer way?

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

Re: Is there a better/nicer way?

Postby Veli-Matti on Sun Mar 28, 2021 4:38 pm

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
Veli-Matti
 
Posts: 72
Joined: Sat Nov 28, 2009 3:12 pm

Re: Is there a better/nicer way?

Postby ArrayMacNB on Sun Mar 28, 2021 5:49 pm

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.
ArrayMacNB
 
Posts: 9
Joined: Tue Sep 01, 2020 3:03 pm

Re: Is there a better/nicer way?

Postby Phil Last on Mon Mar 29, 2021 5:41 pm

20210329_171735.jpg
Morten|Dyalog wrote:"Flat" APL rocks!
User avatar
Phil Last
 
Posts: 572
Joined: Thu Jun 18, 2009 6:29 pm

Previous

Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest