8 years ago (it took me some time even to remember) this problem was solved 
(much) more generally 
http://www.jsoftware.com/pipermail/general/2004-May/017503.html

   1 3 1 3 2 strikeb2~ 1 2 3 1 9 10 8 1 2 3
9 10 8 1 2


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: programming-boun...@forums.jsoftware.com 
> [mailto:programming-boun...@forums.jsoftware.com] Namens June Kim (???)
> Verzonden: woensdag 12 september 2012 7:50
> Aan: programm...@jsoftware.com
> Onderwerp: Re: [Jprogramming] Removing n occurences
> 
> Hi Roger,
> 
> Thanks, Roger, as always. I am aware of that wiki page, but I think it's a
> more general approach. How could I use that to make removen simpler and
> more elegant?
> 
> Best regards
> 
> June
> 
> On Tue, Sep 11, 2012 at 3:42 PM, Roger Hui <rogerhui.can...@gmail.com>wrote:
> 
> > You may want to look at
> > http://www.jsoftware.com/jwiki/Essays/Progressive%20Index-Of
> >
> >
> >
> > On Mon, Sep 10, 2012 at 11:37 PM, June Kim (김창준) <junea...@gmail.com>
> > wrote:
> >
> > > Hello
> > >
> > > If you want to remove all occurences of x in y, it's simple in J:
> > >
> > > y-.x
> > >
> > > For example,
> > >
> > >    1 2 3 1 9 10 8 1 -. 1
> > > 2 3 9 10 8
> > >
> > > Now, if you want to remove n occurences of x in y, how would you do that?
> > >
> > > Following is my quick and dirty solution:
> > >
> > >    removen=.13 : 'y#~-.((x>:]) *. 0&~:) (*+/\) (={.)y'
> > >    3 removen 'fasdffgh  flkjffif'
> > > asdgh  flkjffif
> > >    3 removen 1 1 2 3 1 9 10 8 1
> > > 2 3 9 10 8 1
> > >
> > > I used the first item in y as the "item to remove" -- smiliar to the cut
> > > verb.
> > >
> > > I believe there are simpler solutions as always(you may relax the
> > constrain
> > > for keeping the order of y). Any suggestions?
> > >
> > > June
> > > ----------------------------------------------------------------------
> > > 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

Reply via email to