You can do this with the pretty basic scheme of:

    (A) Enumerate all indicies
    (B) Count the number of equal parts of each index
    (C) Indicate those whose equal-part-count is 2 or more.

Thus:  
   
           indA  =.  $ #: [: i. */@: $             NB.  Enumerate
           indB  =.  { @: (i.&.>) @: $ 
              
           eqInd =.  [: >./ #/.~                   NB.  Count
           
           gdA   =:  $ $ 1 < eqInd"1@:indA  f.     NB.  Indicate
           gdB   =:      1 < eqInd&>@:indB  f.
           
           gdA i. 3 3                             
        1 0 0
        0 1 0
        0 0 1

           gdB i. 3 3
        1 0 0
        0 1 0
        0 0 1


This will not be efficient for large arguments.

-Dan

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to