Re: Fast "locate" function
- Posted by euman at bellsouth.net Dec 06, 2001
- 341 views
This is a shot in the dark so be carefull I havent tested this.... Let me know if it works... > sequence s1, s2 > integer i1 > s1 = {#00,#00,#00,#30} -- constant data > s2 = {#27,#20,#00,#00,#00,#30,#20,#40} > i1 = find(s1,s2) function find_all(object test, sequence data) integer ix, jx, kx, len sequence loc loc = repeat(0,length(data)) ix = 1 kx = 1 len = length(data) jx = find( test, data[ix..len] ) loc[kx] = jx while jx do ix += jx jx = find( test, data[ix..len] ) kx += 1 loc[kx] = jx jx += 4 end while ix = find(0,data) loc = loc[1..ix] return loc end function sequence locations locations = find_all(#00, s2)