Bob,

I found some interesting/surprising results by delving further into your
analysis.

First,  this looks like what Henry had in mind.

   tess     cp;._3"2&.( 0 1&|:)i.7 10 3
 33  34  35
 42  43  44
 51  52  53

123 124 125
132 133 134
141 142 143

But even though the following two transposes seems identical there is a
later surprise.

   (2 0 1&|: -: 0 1&|:) i. 7 10 3
1

And here is an unexpected surprise. Why is this an error.

   tess     cp;._3"2&.(2 0 1&|:)i.7 10 3
|index error
|   tess     cp;._3"2&.(2 0 1&|:)i.7 10 3

Second, to return to the timing issue, Henry's approach does seem to be
(much) faster.

   trimhb =: tess&(cp ;._3)"2 &.(0 1&|:)
   100000 timespacex 'trimhb i. 7 10 3'
2.84443e_5 31744
   100000 timespacex 'trimalt i. 7 10 3'
3.79653e_6 7040

Third, one more observation that is somewhat irrelevant, but neat, involves
the intelligence of the j interpreter in this case. Look at the
(intelligence of?) the last line below where the boxed portion is
translated to display in linear representation (provided 9!:3]5 is set).

   tr i. 7 10 3
+-----------+
|+---+-----+|
||1 4|1 4 7||
|+---+-----+|
+-----------+
   (tr i. 7 10 3)&{
(<1 4;1 4 7)&{
   (tr i. 70 100 3)&{
(<(1+3*i.23);1+3*i.33)&{

And thank you for the detailed explanation you provided.

The beat goes on ...
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to