Tool of Thought

APL for the Practical Man


July 8, 2022

In a previous post we computed the median on grouped data by replicating it and applying a median function that works on ungrouped data. I assumed that there was a way to compute the median without replicating the data, and sure enough, Brother Statistician Steve sent me this old (pre-interval index) solution (slightly modified for explanatory purposes):

    ⍝ ⍺ ←→ Frequency
    ⍝ ⍵ ←→ Values


Looking at:



the function train jumps right off the monitor:



As an aside, trains come in two styles. First is the Orange Blossom Special style, of which this is a prime example. These trains are elegant, a great pleasure to ride. Then we have the Amtrak style, which is a mess of tacks, jots, and tildes diaeresis. (I'm guessing that is the proper plural form, and not tilde diaereses.) These trains are all glue and duct tape. A terrible travel experience. One is better off taking the dfn.

But the point of this post is that it never occurred to me that trains work in FlipDB. And why wouldn't they?! In the FlipDB session:

                (sum running / sum) 7 1 3 1
│1           │


So we can use trains anywhere, in a where clause, a select clause, a having clause, anywhere a FlipDB expression is called for.

Ten minutes after Steve sent over the solution above he sent a new one using interval index, and catching the train too.