I used to do this kind of thing all the time (in the '90s), and was
disappointed how slow it was in J.

I'm not going to recreate any of that code right now, but here's a
simple example problem:

Given a delimited string of item names (the kind that you might break
into pieces with <;._1), put ', ' between each item except the last
one which gets ' and '. (And, just for fun, imagine that the last item
contains a parenthesized list which contains commas -- but note that
technically you don't need the delimiters at all -- they're a
convenient way of marking the items, but you might have had some other
way of getting their positions and lengths).

To solve this, you could get the delimiters of the items, append to
the original string the two additional strings ('/, / and ' for
example though more likely you'll have newline or null as the
delimiter, assuming you're using delimiters), and then construct
indices and lengths to build the final result.

Thanks,

-- 
Raul

On Mon, Jul 8, 2019 at 11:04 AM R.E. Boss <r.e.b...@outlook.com> wrote:
>
> Can you give an example?
>
>
> R.E. Boss
>
>
> > -----Oorspronkelijk bericht-----
> > Van: Programming <programming-boun...@forums.jsoftware.com>
> > Namens Henry Rich
> > Verzonden: zondag 7 juli 2019 20:49
> > Aan: programm...@jsoftware.com
> > Onderwerp: [Jprogramming] Fast substring collection
> >
> > I just want to read this into the record.
> >
> > The task: to run substrings of a string y together in a single list, where 
> > the
> > substrings are given by an nx2 table x of (start,length) pairs.
> >
> > The best solution is:
> >
> > x (,."1@[ ;@:(<;.0) ]) y
> >
> > (as of the next 9.01 beta).
> >
> > The ,."1@[ creates a virtual block; the ;@:(<;.0) creates a virtual block 
> > for
> > each substring AND calculates the length of the final result as it goes
> > along.  The characters are moved only once.
> >
> > This is not special code; it's code that takes advantage of the features 
> > that
> > are generally available.
> >
> > Henry Rich
> >
> > ---
> > This email has been checked for viruses by AVG.
> > https://www.avg.com
> >
> > ----------------------------------------------------------------------
> > 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