two-item trivia
1 post
• Page 1 of 1
two-item trivia
FYI: At first I was surprised that link-commute is faster than dup:
{⍵ ⍵}0 ⍝ dup
0 0
{⍺ ⍵}⍨0 ⍝ link-commute
0 0
)copy dfns cmpx
... saved ..
cmpx'{⍵ ⍵}0' '{⍺ ⍵}⍨0'
{⍵ ⍵}0 → 1.2E¯6 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
{⍺ ⍵}⍨0 → 9.7E¯7 | -20% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Then I remembered that link is an idiom and that dup isn't. Perhaps it should be.
I wonder if pairs of items occur frequently enough to merit a little extra attention from the interpreter?
{(↑⍵)(1↓⍵)} ⍝ head & tail ⎕ml≥2
{⍵}∘⍺⍺\∘{⍵ ⍵} ⍝ (arg)(⍺⍺ arg)
↑{...}/A B ⍝ {...} applied once, so A{...}B could be a tail call.
...
{⍵ ⍵}0 ⍝ dup
0 0
{⍺ ⍵}⍨0 ⍝ link-commute
0 0
)copy dfns cmpx
... saved ..
cmpx'{⍵ ⍵}0' '{⍺ ⍵}⍨0'
{⍵ ⍵}0 → 1.2E¯6 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
{⍺ ⍵}⍨0 → 9.7E¯7 | -20% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Then I remembered that link is an idiom and that dup isn't. Perhaps it should be.
I wonder if pairs of items occur frequently enough to merit a little extra attention from the interpreter?
{(↑⍵)(1↓⍵)} ⍝ head & tail ⎕ml≥2
{⍵}∘⍺⍺\∘{⍵ ⍵} ⍝ (arg)(⍺⍺ arg)
↑{...}/A B ⍝ {...} applied once, so A{...}B could be a tail call.
...
- JohnS|Dyalog
1 post
• Page 1 of 1
Return to Functional Programming
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group