It seems unrealistic to expect more than I have - sorry,  I will try to
tune other parts.

The first instance of doSL is already as close to the cut conjunction as it
can get (I thought ravel items applied with rank"1 is costly - it is not)


6!:2 '(1e6 $ ''ab''xmlTagContentSL XML) #doSL XML'

0.876747

6!:2 '(,."1@[ 1e6 $ ''ab'' xmlTagContentSL XML)'

0.032107

2017-06-11 14:19 GMT+03:00 Danil Osipchuk <[email protected]>:

> Hi all,
>
> I wonder if there is an idiomatic way to apply a verb using an array of
> start and length pairs. This is a recurring pattern when extracting data
> from files.
> I've tried 3 adverbs (the example at the end), and the first one is
> slightly better on big files, but I'm still looking for possible
> improvements (the need is to extract selected fields from multi-gigabyte
> memory mapped csv/xml files)
>
> 'ab' xmlTagContentSL XML
>
> 11 1
>
> 22 2
>
> 34 3
>
> 47 4
>
> 'ab' <xmlTagDo XML
>
> +-+--+---+----+
>
> |1|20|300|4000|
>
> +-+--+---+----+
>
> (2 2 $ 'ab'xmlTagContentSL XML) <doSL XML
>
> +---+----+
>
> |1 |20 |
>
> +---+----+
>
> |300|4000|
>
> +---+----+
>
>
> regards,
> Danil
>
> doSL =: 1 : '(,."1@[)u;.0]' NB. SL stands for start len pair
>
> NB. doSL =: 1 : '(0|:[:,:[)u;.0]'
>
> NB. doSL =: 1 : '(u;.0~ ,.)~"1'
>
>
> xmlTagOpn =: '<' ,'>',~]
>
> xmlTagCls =: '</','>',~]
>
>
> xmlTagContentSL =: 4 : 0
>
> CS =. (xmlTagOpn >x) (#@[ + I.@E.) y
>
> CE =. (xmlTagCls >x) I.@E. y
>
> CS ,. CE-CS
>
> )
>
>
> xmlTagDo =: 1 : '(xmlTagContentSL (u doSL) ])f.'
>
>
> XML =: 0 : 0
>
> <data>
>
> <ab>1</ab>
>
> <ab>20</ab>
>
> <ab>300</ab>
>
> <ab>4000</ab>
>
> </data>
>
> )
>
>
>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to