Tally, rho and idioms

General APL language issues

Tally, rho and idioms

Postby gumont68 on Wed Mar 27, 2019 5:45 pm

Hello,
I like the tally, but because of this:
cmpx '0≠⊃⍴v' '0≠≢v '
0≠⊃⍴v → 7.1E¯8 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠≢v → 1.4E¯7 |+98%⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕

..it's unconfortable to use it. Is there any chance that also the expression with the tally could become an idiom?
Thanks.
Guido
gumont68
 
Posts: 2
Joined: Fri Oct 19, 2018 10:22 am

Re: Tally, rho and idioms

Postby Veli-Matti on Thu Mar 28, 2019 9:13 am

Hmm.. which version are you using?
I asssume that the v in your example refers to a vector, thus the quick testing in my (Dyalog 17.0/Unicode/32-bit/Win 7/[]ML 3) gives

      v←⍬
]runtime "~0∊⍴v" "0≠≢v" "0≠↑⍴v" -compare

~0∊⍴v → 4.5E¯8 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠≢v → 5.9E¯8 | +33% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠↑⍴v → 8.2E¯8 | +83% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕

v←⍳123
]runtime "~0∊⍴v" "0≠≢v" "0≠↑⍴v" -compare

~0∊⍴v → 4.1E¯8 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠≢v → 5.2E¯8 | +27% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠↑⍴v → 9.3E¯8 | +126% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕


In other words
      0∊⍴
is my preferred idiom to use here - but tally does a quite nice job, too.
-wm
Veli-Matti
 
Posts: 46
Joined: Sat Nov 28, 2009 3:12 pm

Re: Tally, rho and idioms

Postby gumont68 on Thu Mar 28, 2019 1:27 pm

Hi Veli-Matte. Happy to hear from you. Thanks for your answer.
v←⍳20⋄cmpx '~0∊⍴vvv' '0≠≢v' '0≠⊃⍴v'
~0∊⍴vvv → 8.1E¯8 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠≢v → 2.1E¯7 | +157% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠⊃⍴v → 8.5E¯8 | +4% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Your favourite expression, I can guess, is and idiom just as 0≠⊃⍴ is.
I like most ≠≢v only because is one char less.
But i see my favourite expression it is not a idiom.. so...
The weird thing is that in my version the difference is bigger, but it can depend on some other computer magic.
Apl 17 64 Unicode. cmpx is the one from the dfns library.

PS. Too bad that the tally comes out with a bit weird typo, here..
Guido
gumont68
 
Posts: 2
Joined: Fri Oct 19, 2018 10:22 am

Re: Tally, rho and idioms

Postby Veli-Matti on Thu Mar 28, 2019 3:48 pm

Oh my, there's always something new to learn. I am an old APL2 bigot, and that's why the results were different (the ]runtime user command is handy because I don't have to copy the function in the workspace, but AFAIK the underlying code is the same):

      v←⍳12 ⋄ ⎕ML←1
]runtime "~0∊⍴v" "0≠≢v" "0≠⊃⍴v" -compare

~0∊⍴v → 6.7E¯8 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠≢v → 1.5E¯7 | +116% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠⊃⍴v → 7.4E¯8 | +11% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕

⎕ML←3
]runtime "~0∊⍴v" "0≠≢v" "0≠↑⍴v" -compare

~0∊⍴v → 7.1E¯8 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠≢v → 1.5E¯7 | +111% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
0≠↑⍴v → 2.0E¯7 | +184% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕


Seemingly I have to reread the idiom list more carefully!
-wm
Veli-Matti
 
Posts: 46
Joined: Sat Nov 28, 2009 3:12 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest