Simple arrays are simple to output.
The problem is really nested arrays within nested arrays within ... I finally found an algorithm which uses two
passes, but formats the numbers only once (see the code in pf_dtackjot.c).
However there might well be some gaps, especially w.r.t. spacing and positioning.
For example, APL2 has some rules for how nested arrays should be displayed:
- There is one column each of leading and trailing blanks.
- Character scalar and vector items in columns containing numeric scalars are right-justified.
- Character scalar and vector items in columns not containing numeric scalars are left-justified.
- Row and column spacing is determined by the context of adjacent items. The spacing increases with the rank of the items. The number of embedded blanks is one less for character items than for other items.
- The definition of the default format function is applied recursively so that nested items within a nested array appear with a leading and trailing blank.
- How well have these rules stood the test of time?
- Are they sufficient for basic output needs?
- How does this compare with the way other systems implement raw output?