You just need to get rid of the ~ : 1 [`]`(0 $~>:@(>./)@])} ia
This is the implementation I would use. I don't see the need for special code, since the old code seems fast enough. On your earlier point, !. can be used on bigger-than-primitives: f/.!.0 is one I use. It makes sure that intolerant comparison is used on the grouping performed by /. . Henry Rich On 9/5/2010 10:54 PM, Marshall Lochbaum wrote: > On the Boolean case, which I would consider the most important, ([: > <:@(#/.~) i.@>:@(>./) , ]) is not optimal: > a=.0.1> 100000 ?...@$ 0 > ia=.I. a > 6!:2 '([:<:@(#/.~) i.@>:@(>./) , ]) ia' > 0.00682521 > 6!:2 '(e.~ i.@>:@(>./)) ia' > 0.002004 > 6!:2 '1 ia} (0 $~>:@(>./)) ia' > 0.000679754 > > So if this is implemented well, there should be some special code for that. > On that last method: I can't seem to make it into a single verb. When I > input > 1 [`]`(0 $~>:@(>./)@])}~ ia > > I get a rank error. Also of note, if I use (,1) instead of 1 I get a length > error--does the gerund amend just not support extending a scalar? > > Marshall > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Raul Miller > Sent: Sunday, September 05, 2010 7:41 PM > To: Programming forum > Subject: Re: [Jprogramming] Mask from list of indices with multiplicity > > On Sun, Sep 5, 2010 at 6:19 PM, Marshall Lochbaum > <[email protected]> wrote: >> I do really like the idea of this being I.^:_1. A lot of times I have >> had an array of indices that I would like to get to an array of 1s, >> and I have been forced to use something like (i.n) e. l (list is l, max > index is n). >> Making I.^:_1 equal to ([:<:@(#/.~) i.@>:@(>./) , ]) would be really >> useful. > > And perhaps !. could be used to specify the maximum index if<./ gets that > wrong? > > -- > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
