Is there a better/nicer way?
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 !
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 !
13 posts
• Page 2 of 2 • 1, 2
Re: Is there a better/nicer way?
If that @ wasn't so slow...
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
⍝
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: 93
- Joined: Sat Nov 28, 2009 3:12 pm
Re: Is there a better/nicer way?
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.
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?
Morten|Dyalog wrote:"Flat" APL rocks!
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
13 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group