x =. 5 6 ,: 1 3 NB. Two substrings as start,length
y =. 'abcdefghijklmnopqrstuvwxyz'
x (,"0@[ ;@:(<;.0) ]) y NB. fetch & catenate substrings
fghijkbcd
Henry Rich
On 7/8/2019 11:04 AM, R.E. Boss 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