Bordering in the Dyalog 8.2 review
Vector 15:3, page 7
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 7
Your article on Dyalog APL/W 8.2 had an example on p.26 of Vector 15.2. It occurred to me that the bordering could be done in two steps, possibly with a slight saving in time. I wrote them in J and my hunch was right:
Functions f and g give identical results on boolean matrices. The function f is the same as your APL expression, where a complete border of zeros surrounds the matrix before any reductions occur. The function g puts rows of zeros on top and bottom only, inserts + between the rows, then puts columns of zeros on the left and right of this temporary result, and inserts + between the columns. Timings give g a 20% edge over f on small matrices such as one encounters in Life games.
A very small point probably not worth worrying about, but when one has learned to program in the 1950s, like me, the habit of looking for any small edge is hard to forsake.