Dan - it _was_ an accurate transcription.  However, I neglected to check the
definition of "each":

  each
"0

in my session.  If I substitute what I assumed it was, &.>, the whole
problem makes a lot more sense.

Using the trick you taught me, we find the offending redefiner:

  (4!:4{.;:'each') {:: 4!:3''
c:\program files\j601\system\extras\util\browser.ijs


On 3/30/07, Dan Bron <[EMAIL PROTECTED]> wrote:

Devon,

Are you sure the message quoted below contains an accurate transcript of
your J session?  Here's what I get:


           table =. ,. each <"1 & |: i. 4 3

           (>,.&.>/table) ; |:;"2 table
        +-------+-------------------------+
        |0  1  2|0 3 6 9 1 4 7 10 2 5 8 11|
        |3  4  5|                         |
        |6  7  8|                         |
        |9 10 11|                         |
        +-------+-------------------------+

           (>,.&.>/table) -: |:;"2 table
        0

           $|:;"2 table

        1 12

           $>,.&.>/table
        4 3

           $table
        3

I think this last result is the crux:  your  table  and my  table  are
different.  I have no unit axes.  Mine is a simple vector of 3 boxes, each
containing a single column of numbers (each with shape  4 1  ).

A formulation equivalent to yours, but with the noun  table  as given,
would be:


           |:@:(,"2)>table
        0  1  2
        3  4  5
        6  7  8
        9 10 11

or:

           ,"2@:(0&|:)@:> table
        0  1  2
        3  4  5
        6  7  8
        9 10 11

in either case, you could use  {.  (head) in place of  ,  (ravel)  .

And you're right, as far as I can deduce, these formulations give results
equivalent to  >@:(,&.>)/  (with exceptions for corner cases like  0 e. $
table   ?) .  And the performance metrics may differ, because there are
many, small intermediate arrays in the  ,.  solution, as opposed to the few,
large ones in the  |:  solutions.


-Dan


----- Original Message ---------------

Subject: Re: [Jprogramming] Unboxing Columns
   From: "Devon McCormick" <[EMAIL PROTECTED]>
   Date: Fri, 30 Mar 2007 15:23:31 -0400
     To: "Programming forum" <[email protected]>

>Well, admittedly,
>
>   table =. ,. each <"1 & |: i. 4 3
>   (>,.&.>/table) ; |:;"2 table  NB. The results look the same
>+-------+-------+
>|0 1 2|0 1 2|
>|3 4 5|3 4 5|
>|6 7 8|6 7 8|
>|9 10 11|9 10 11|
>+-------+-------+
>   (>,.&.>/table) -: |:;"2 table  NB. but aren't
>0
>   $|:;"2 table                       NB. because
>4 3
>   $>,.&.>/table
>1 1 4 3
>
>In my experience, extra, singleton axes are as much a
>nuisance as anything else.
>
>Of course, maybe they are present in the original array for a reason
>and need to be retained?
>
>   $table
>3 1 1
>
>
>On 3/30/07, Dan Bron <[EMAIL PROTECTED]> wrote:
>>
>> RM = Raul Miller, DM = Devon McCormick
>>
>> RM> Personally, I would phrase that as
>> RM>    >,.&.>/table
>>
>> DM>I think
>> DM>   |:;"2 table
>>
>> Tsk.  That's like recommending a book you haven't read.  Try running
that
>> line...
>>
>> By the way, Leigh, if you promise that  table  is a vector of at least
two
>> boxes, then you can shorten your verb a bit:
>>
>>     ,.&:>/ table
>>
>> But the general case is much nicer with  >@:(,.&.>/)  which is faster
and
>> leaner anyway.
>>
>> -Dan
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
>
>--
>Devon McCormick, CFA
>^me^ at acm.
>org is my
>preferred e-mail
>----------------------------------------------------------------------
>For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm




--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to