Here's mine, not elegant.  --Kip

    A
 abcabbe
    B
 babe
    rfo  NB. remove first of only one letter
 ] #~ [: -. i.~ = [: i. [: # ]
    'b' rfo A
 acabbe
    rfob  NB. one step of cless, boxed
 ([: }.&> {.) ; ([: {.&> {.) rfo [: > {:
    rfob B;A
 +---+------+
 |abe|acabbe|
 +---+------+
    cless
 4 : '> {: rfob^:(#y) y ; x'
   A cless B
 cab

On Monday, January 18, 2016, June Kim (김창준) <[email protected]> wrote:

> Hi Roger,
>
> As usual, thanks for the insightful answer. I think Progressive Index-of is
> such a widely useful verb, it would be a good idea to include it in the
> base library. Or is it already?
>
> On Mon, Jan 18, 2016 at 1:41 PM, Roger Hui <[email protected]
> <javascript:;>>
> wrote:
>
> > This is a variant of progressive index-of
> > <http://code.jsoftware.com/wiki/Essays/Progressive_Index-Of> (pi below).
> >
> >    oc=:    i.~ (] - {) /:@/:
> >    pi=:    #@[ ({. i.&(,. oc) }.) [ i. ,
> >    pless=: [ {~ i.@#@[ -. pi
> >
> >    'abcabbe' pless 'abbe'
> > cab
> >
> >    'Mississippi' pless 'i'
> > Mssissippi
> >    'Mississippi' pless 'ii'
> > Mssssippi
> >    'Mississippi' pless 'iii'
> > Mssssppi
> >
> >
> >
> >
> > On Sun, Jan 17, 2016 at 8:19 PM, June Kim (김창준) <[email protected]
> <javascript:;>>
> > wrote:
> >
> > > Hello
> > >
> > > I am looking for a verb(cless) that does something similar to Less(-.)
> > but
> > > counting the elimination, for example:
> > >
> > >    'abcabbe' -. 'abbe'
> > >
> > > c
> > >
> > >    'abcabbe' cless 'babe'  NB. get rid of y letters counting the
> > > occurrences
> > >
> > > 'cab'
> > >
> > >
> > > It is easier to define such a verb recursively: 'abcabbe' cless 'babe'
> > > equald to 'e' cless~ 'b' cless~ 'a' cless~ 'b' cless~ 'abcabbe'
> > >
> > >
> > > I think recursive definition isn't a usual J-ic approach.
> > >
> > >
> > > How would you implement such a verb elegantly(with which I mean short)?
> > >
> > >
> > > 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



-- 
Sent from Gmail Mobile
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to