Invincible summer |||

The rest is silence

The Array Cast

In the latest episode of the Array Cast we discussed tacit programming but perhaps did not say enough about what we meant.

So here is a tiny example of a useful tacit expression.

From the very beginning I wanted my APL functions to look like extensions of the language. Not the style I had learned with Fortran

      ∇ MAIN
[4]  ∇

John Backus
John Backus



Although I did not then know the term, functional programming was in the air. “APL was the primary influence on John Backus’s FP” – and why Backus proposed Ken Iverson for the Turing Award.

So my inner aesthete was excited by Ken’s internal paper at I.P. Sharp Associates that used what he called “direct definition”.

PLUS: ⍺ + ⍵

And John Scholes eventually implemented a version of direct definition in Dyalog APL as ‘dfns’.

plus ← {⍺ + ⍵}

I often want the members of an integer range. Say, a range of 5 11 should return 5 6 7 8 9 10.

Clearly it involves the the APL Index Generator – til in q.

0 1 2 3 4 5 6 7 8 9 10
q)til 11
0 1 2 3 4 5 6 7 8 9 10

Traditional APL suggests keeping a ‘utility’ function around.

      ∇ RANGE
[0]   Z←X RANGE Y
[1]   Z←X+⍳Y-X
[2]  ∇
      5 RANGE 11
5 6 7 8 9 10

Lambdas are less fuss.

5 6 7 8 9 10
q){x+til y-x}[5;11]
5 6 7 8 9 10

or, given the range as a pair

      ⊃{⍺+⍳⍵-⍺}/5 11
5 6 7 8 9 10
q){x+til y-x}. 5 11
5 6 7 8 9 10

Above, the q Apply operator (.) applies its lambda left argument to a list of its two arguments. The APL solution gets there by using the lambda to reduce the pair, and must then Disclose the result.

This still seemed too much ‘ceremony’ for something so simple. I wanted more. Or rather, I wanted less.

A two-operator version is as efficient for small arguments.

      ⊃{⍺↓⍳⍵}/5 11
5 6 7 8 9 10
q){x _ til y}. 5 11
5 6 7 8 9 10

The Bind operator in Dyalog APL allows me one more step. I can replace {⍺↓⍳⍵} with ↓∘⍳.

      ⊃↓∘⍳/5 11
5 6 7 8 9 10

Wouldn’t it be nice?

John Scholes
John Scholes

WIBNI (wouldn’t it be nice if) was a favourite coinage of John Scholes.

WIBNI we could borrow q’s Apply operator? As an APL operator it would derive from a dyadic function a monadic function that takes the dyadic’s two arguments as a 2-element array.

      ↓∘⍳. 5 11
5 6 7 8 9 10

Now we’re cooking. A simple tacit expression for range: ↓∘⍳.. No ceremony. You could hear a pin drop. You could hear yourself think.

Up next Bergh Apton revisited The democracy of narcissism
Latest posts All that jazz: The librarian’s song Sandals on their way home A short history of the Australian Flat White Cycling glove, slightly foxed Untoward occurrence at embassy poetry reading To Go to Lvov The founding of Iverson College The pot-boy’s story Prisoners of our own device How green is my valley The ghost in the shell Finding primes with q Policing protests in Glasgow Why don’t we do it in the road? The democracy of narcissism The rest is silence Bergh Apton revisited What makes a language flourish? A duty of care Crispbread economics Learning vector programming The Underground The Post Office scandal A plea for simplicity BoJo the clown Days are of two kinds Trollope What we saw in Roswell The orkestra bows out Imagine Hampstead village and South End Green with no through traffic What makes this so dangerous