two-item trivia

For users of dfns, both novice and expert

two-item trivia

Postby JohnS|Dyalog on Mon Apr 12, 2010 12:45 pm

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.
      ...
JohnS|Dyalog
 

Return to Functional Programming

Who is online

Users browsing this forum: No registered users and 1 guest