train-spotting

For users of dfns, both novice and expert

train-spotting

Postby Phil Last on Wed Oct 22, 2014 9:41 am

It's easy and fun to code stuff like
      quoted ← ≠\ ''''=⊢ 
needed ← quoted ≥ ' '⍷⊢
The next step naturally would be
      squeeze ← needed / ⊢
but of course / is one of these damned hybrids and in this case we have to tell APL to treat it as a function because it reads this as the two-train atop
      (needed/) ⊢
This led me in steps to
      needed (/⍨⍨) ⊢
which worked but then I saw what I was doing and finally came up with
      squeeze ← ⊢ (/⍨) needed
which is a full 25% quicker than its dfn equivalent. I'm beginning to see the argument for a separate glyph for the function compress/replicate as opposed to operator reduce/insert.

p.s. with
      ]box -trains=parens
we get
      squeeze
⊢(/⍨)(((≠\)('''=⊢))≥(' '⍷⊢))
which would be perfect with an extra quote. I can't complain as my attempt at an operator to represent dervs generally produces nonsense with array operands.
User avatar
Phil Last
 
Posts: 624
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Return to Functional Programming

Who is online

Users browsing this forum: No registered users and 1 guest