VCAT in Sharp APL
Vector 7:1, page 113
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 113
I was interested to see Norman Thomson’s note "VCAT: A Response" in Vector 6, 3. He provides a "modern didactic view" of the problem which, as your editor points out, is slower than the "antique, pragmatic" utility which it offers to supplant. It is, of course, not at all uncommon for the initial implementation of a new feature to be slower than the facility it is intended to replace; when the implementors have enough experience (or often enough complaints from customers) they often find ways to make the new facility more competitive in speed.
I can report, however, on an alternative which is also modern, and while I can hazard no guess as to its didactic merits, I do know that it has the merits of being much shorter even than Mr Thomson’s solution, handles the degenerate cases of scalar and vector arguments with no extra fuss, and is faster than the antique it can replace.
The solution is written in Sharp APL. The view of the problem it takes is influence by the design of the monadic format function and by the availability of the table, or matrix-making primitive. A boxed list of the arguments is formed using the link function: l⊃r; this two-element list is made into a two-by-one matrix, using the table function: ⍪l⊃r; and this is formatted using monadic thorn, which has the property that it expands boxed items to match the largest in size: ⍕⍪l⊃r. That’s all there is to it.
Here is the whole function:
Timings made on the Sharp mainframe system for arguments of varying sizes are as follows:
+-------------------------------------------+
| | | z←l vcat r |
| ⍴left | ⍴right | eem | PB |
| | | vcat | VCAT |
|---------|---------|-----------|-----------|
| 2 5 | 3 3 | 118 | 115 |
| 12 80 | 23 | 125 | 112 |
| 56 132 | 63 | 137 | 131 |
|100 200 |300 30 | 270 | 320 |
+-------------------------------------------+
Yours faithfully
Eugene McDonnell