Well... heading in the tacit direction there's this: NB. explicit verb ritemE=: 1 :0 : x (I.m-:"_1 _ y)} m )
NB. tacit verb ritemT=: 1 :0 [`([:I. m -:"_1 _ ])`(m"_)} ) NB. some sample data and tests C=:3 4$i.8 A=:i.3 2 4 assert 9 8 7 6 (C ritemE -: C ritemT) 0 1 2 3 assert (100%i.2 4) (A ritemE -: A ritemT) 16+i.2 4 But I do not think you can eliminate the 1 : without either significant verbosity or a modified interpreter. -- Raul On Thu, Mar 10, 2016 at 1:59 AM, Ben Gorte - CITG <[email protected]> wrote: > I'm afraid I don't know how do this tacitly ... > > ritem =: 1 : (':' ; 'x (I.m-:"_1 _ y) } m') > > (2 4$0) (i.3 2 4) ritem 16+i.2 4 > 'a' 'P&n&m&k&n&&l' ritem '&' > > ... but m is in its place and it doesn't box. > > Ben > ________________________________________ > From: Programming [[email protected]] on behalf of > Pascal Jasmin [[email protected]] > Sent: Thursday, March 10, 2016 00:57 > To: [email protected] > Subject: Re: [Jprogramming] Replace Items > > moving around the m term to be the "searched". There's probably a better > version that doesn't box. > > > ritem =: 1 : '(m -:"_ _1 ]) >@:({"0 1) (,&<~"_ _1)' > (2 4 $ 0) (16+i.2 4) ritem i. 3 2 4 > > > > ----- Original Message ----- > From: Kip Murray <[email protected]> > To: "[email protected]" <[email protected]> > Sent: Wednesday, March 9, 2016 5:26 PM > Subject: [Jprogramming] Replace Items > > Adverb ritem creates a verb which replaces by x items in array m that > match y > > Below are examples. How would you write the adverb? --Kip Murray > > > C > 0 1 2 3 > 4 5 6 7 > 0 1 2 3 > 0 0 0 0 C ritem 0 1 2 3 > 0 0 0 0 > 4 5 6 7 > 0 0 0 0 > A > 0 1 2 3 > 4 5 6 7 > > 8 9 10 11 > 12 13 14 15 > > 16 17 18 19 > 20 21 22 23 > (2 4 $ 0) A ritem 16+i.2 4 > 0 1 2 3 > 4 5 6 7 > > 8 9 10 11 > 12 13 14 15 > > 0 0 0 0 > 0 0 0 0 > > > > > -- > Sent from Gmail Mobile > ---------------------------------------------------------------------- > 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 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
