Ben's suggestion works for this "weird" use of I.

   I. 2 3 4 1 
0 0 1 1 1 2 2 2 2 3 

     ([: +/ ( 1 ,~ I.)"0) I. 2 3 4 1 
2 3 4 1 

But, I just wanted a way to get boolean data.  Its pretty straightforward to 
get trailing 0s

   ([: +/ ( 1 ,~ I.)"0) 7 9 
0 0 0 0 0 0 0 1 0 1 
   16 $ ([: +/ ( 1 ,~ I.)"0) 7 9 
0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 

though I guess, there is:

   1 (7 9 }) 16 $ 0 
0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 

but I don't believe it can be structured as an inverse to I. because we don't 
know what the original size (shape) was.  If we accept to "unfill" the inverse 
then this could be faster:

   I. :. (3 : ' 1 y} (>: >./y) $ 0') inv 7 9 
0 0 0 0 0 0 0 1 0 1 

   I. <: &. (I. :. (3 : ' 1 y} (>: >./y) $ 0')) ([: +/ ( 1 ,~ I.)"0) 7 9 
6 8 



----- Original Message -----
From: greg heil <[email protected]>
To: Programming forum <[email protected]>
Cc: 
Sent: Saturday, October 11, 2014 2:24 PM
Subject: Re: [Jprogramming] an inverse to I.

Pascal

Indeed taking them one at a time seems to work
... though REB's objection still stands:

   Ii &> I. each <"1 [2 16$0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 1
0 0 0 0 0 0 0 1 0 1

greg
~krsnadas.org

--

from: 'Pascal Jasmin' via Programming <[email protected]>
to: "[email protected]" <[email protected]>
date: 11 October 2014 10:08
subject: Re: [Jprogramming] an inverse to I.

though this works:

  ([: +/ ( 1 ,~ I.)"0) &> I. each <"1 >:/~ i.3

1 0 0
1 1 0
1 1 1

--

from: greg heil <[email protected]>
to: Programming forum <[email protected]>
date: 11 October 2014 09:49
subject: Re: [Jprogramming] an inverse to I.




   Ii=:   [: +./ ( 1 ,~ I.)"0
   >:/~ i.3
1 0 0
1 1 0
1 1 1
   I. >:/~ i.3
0 0 0
0 1 0
0 1 2
   Ii(I. >:/~ i.3)
1 0 0
1 1 0
1 0 1

greg
~krsnadas.org

--

from: 'Pascal Jasmin' via Programming <[email protected]>
to: Programming forum <[email protected]>
date: 11 October 2014 09:12
subject: [Jprogramming] an inverse to I.

I notice that there is no inverse to I. that is defined.  Is this an
appropriate one?

   ([: +./ ( 1 ,~ I.)"0)  7 9
0 0 0 0 0 0 0 1 0 1

   I. ([: +./ ( 1 ,~ I.)"0) 0 7 9
0 7 9
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to