The Display of Nested Arrays

It's All About Spacing and Positioning

The Display of Nested Arrays

PostPosted by forummaster » Sun May 27, 2007 7:06 pm

I consider array output (along with the parser) to be the two most difficult parts of the interpreter to implement.

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.

Some questions:

  1. How well have these rules stood the test of time?

  2. Are they sufficient for basic output needs?

  3. How does this compare with the way other systems implement raw output?

Posts: 567
Joined: Wed Jan 23, 2013 1:00 pm

Return to Array Output

Who is online

Users browsing this forum: No registered users and 0 guests