[Jprogramming] Definition: Frame of an argument

Dan Bron j at bron.us
Wed Jan 20 20:59:39 UTC 2016


Roger wrote:
> "Empty frame" made sense when a frame was the axes of an array left over
> after you've accounted for the cell.


I don’t remember who introduced me to the idea, but I was first encountered them, enchanted by the definitions:

  -  Axis: index in the shape of an array
  -  Dimension: Value at that index

So the noun  A=:i.5 7 11  has three axes, and the dimensions 5x7x11. You can box along the first axis with 1 <;.1 A, you can box along the second axis with (‘’;1) <;.1 A and you can box along the third axis with  (‘’;’’;1) <;.1 A . 

Or you can move axes around with |: (both monad and dyad) and then use the normal rank mechanisms to address the leading axes of the array*.

Some other primitive which allow you to address non-leading axes of an array are:

  -  ;.  NB. as seen above
  -  |.  NB. the LHA can be a vector of length #$y; each atom in the vector determines how much the corresponding axis of y is rotated
  -  {.  NB. similar to |. except each atom of x determines the corresponding dimension of y . Similarly for }. .
  -  |:  NB. Sorta. Any use changes all axes; some uses change rank too.
  -  }   NB. Sorta; arbitrary amendments; doesn’t require that leading axes be addressed, but all amendments must be rectangular. Cannot alter dimensions. 

Sometimes I’ve wished A. followed the model of |. but currently its left rank is 0 instead of 1 .

It would be an interesting exercise to imagine a J less heavily weighted towards leading axes and “items”. Being able to easily address and manipulate arbitrary axes would move J closer to an RDBMS or BI tool (think of a cube of sales x month x customer x region x product). 

Sometimes you want sales by month, sometimes you want customer by region, sometimes you want product by customer, sometimes you want sales by product by customer … .  These differing perspectives account for e.g. why not all empty arrays are the same: depending on which dimension is 0 (i.e. at which axis), you might have no sales, or no customers, or no months … 

-Dan

* Sometimes, after doing that, you’ll also have to reverse the effects of the transpose (due to rank changes and/or boxing, sadly this often can not be expressed with an elegant &. ).



More information about the Programming mailing list