Or, without using the dyad -. itself in the models, [ #~ i...@#@[ -...@e. i. NB. ordinary dyad -. [ #~ i...@#@[ -...@e. pi NB. "less" required here
----- Original Message ----- From: Roger Hui <[email protected]> Date: Saturday, April 17, 2010 8:29 Subject: Re: [Jprogramming] remove elements (with repetition allowed) To: Programming forum <[email protected]> > This is a variant of the progressive index-of problem. > http://www.jsoftware.com/jwiki/Essays/Progressive%20Index-Of > > Comparing the two "less"es: > [ {~ i...@#@[ -. i. NB. ordinary dyad -. > [ {~ i...@#@[ -. pi NB. "less" required here > > > > ----- Original Message ----- > From: June Kim <[email protected]> > Date: Saturday, April 17, 2010 7:01 > Subject: [Jprogramming] remove elements (with repetition allowed) > To: Programming forum <[email protected]> > > > How would you implement "takeout"(Less with equally valued > cell > > numberssignificant) in the following test cases? > > > > assert 1 2 -:&(/:~) 1 2 3 takeout 3 > > assert (,:1) -:&(/:~) 1 1 1 takeout 1 1 > > assert 1 3 4 -:&(/:~) 1 2 3 4 1 1 takeout 1 2 1 > > assert 1 2 3 -:&(/:~) 1 2 3 3 2 takeout 3 2 > > > > My first quick implementation(without much thought): > > > > keyind=:([:< i...@# ,. ])/.~ > > takeout =: {:"1...@-.&(;@:keyind) > > > > I would appreciate simpler and more elegant solutions. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
