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