>From the discussion so far I conclude the following specs:
0. determine the substring beginning after the first ':' and after
the first ':' after each '+', until the next ':' or the next '+' or end of
string
1. give index and offset of that string
2. let the performance be (much) better than using ;.
idos=: 4 : 0 NB. index & offset; x='+:' y is string
'pl sc'=. x (<@[EMAIL PROTECTED]"0 _) y,{.x
isp=. pl I. sc
isfp=. 1(,~*.,)(}.~:}:) isp
Isfs=. I. (}.< }:) 1,isfp
z=. sc {~ (,:>:) Isfs
z=.z,. (isfp # sc),:pl{~ isfp#isp
(>:@{. ([,.-~) {:) z
)
'+:'idos '+4.31-A+-:H-:H+4.30:A+4.32:A+4.25:A+4.25:'
10 2
20 1
27 1
34 1
41 0
sm '+4.31-A+-:H-:H+4.30:A+4.32:A+4.25:A+4.25:'
7 1
10 2
20 1
27 1
34 1
40 1
NB. "... this sm (...) doesnt provide the result needed"
et=: 6!:2
10 et' sm"1 data'
0.18259416
10 et' ''+:''idos"1 data'
0.54426299
10 et' sm ,data'
0.095853325
10 et' ''+:''idos ,data'
0.324895
So the performance ratio is about 3, much better than cut, but sm still
superior.
R.E. Boss
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens david alis
Verzonden: woensdag 24 januari 2007 7:24
Aan: Programming forum
Onderwerp: [Jprogramming] Re: Programming sequential machine/finite state
machine
That is an interesting suggstion and I will investigate.
My conclusions are (1) a small c program will need to be written to do
what's needed and (2) learning how to program the sm has nevertheless
been worthwhile - it's a magical jewel in the j toolbox.
Thankyou very much for your efforts
David
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm