reduce =: 1 : '<"1@[ ([: i (&.>)/(>@:) ,) <@:]'
   'Mississippi' (] {~ i.@#@] -. i.~) reduce~ 'iii'
|value error: i
|   'Mississippi'    (]{~i.@#@]-.i.~)reduce~'iii'

More general how?  From the looks of it, "reduce" treats the left argument
as an array or rank-1 cells.  Not very general?




On Mon, Jan 18, 2016 at 1:33 AM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:

> There is also the more general
>
> reduce =: 1 : '<"1@[ ([: i (&.>)/(>@:) ,) <@:]'
>
> 'Mississippi' (] {~ i.@#@] -. i.~) reduce~ 'iii'
>
>
>
>
> ----- Original Message -----
> From: Marshall Lochbaum <[email protected]>
> To: [email protected]
> Sent: Sunday, January 17, 2016 11:45 PM
> Subject: Re: [Jprogramming] A Different Less?
>
> Roger got it first, but I wrote a little more than he did, so here it
> is:
>
> This is a very difficult problem in J, and a reasonably good candidate
> for a language primitive. This essay describes a very similar problem
> whose solution is slightly more powerful:
> http://code.jsoftware.com/wiki/Essays/Progressive_Index-Of
> The progressive index-of is related to dyad (i.) in the same way that
> the verb you want is related to (-.). The verb (-.) is equivalent to
> ([ #~ #@] = i.~), and the same relation holds with progressive index-of
> and your desired verb. Thus, using (oc) and (pi) from the essay,
>
>    oc=: i.~ (] - {) /:@/:
>    pi=: #@[ ({. i.&(,.oc) }.) [ i. ,
>    cless =: [ #~ #@] = pi~
>    'abcabbe' cless 'babe'
> cab
>
> I don't find this solution particularly satisfactory since it uses a lot
> of data shuffling that is only tangentially related to the actual
> computation performed. However, the performance is tolerable: it's
> probably a factor of ten off from the speed of a J primitive built for
> the task.
>
> Marshall
>
> On Mon, Jan 18, 2016 at 01:19:24PM +0900, June Kim (김창준) 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to