RE: Slice sequence--new algorithm

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hi Derek,
  You reminded me of a routine i coded quite a while back and
forgot about!  All i used it for was to remove spaces.
It should be quite fast for low target char to other char ratios.
Here it is:

--removes all occurances of n from s:

p=find(n,s)
while p do
    s=s[1..p-1]&s[p+1..length(s)]
    p=find(n,s)
end while


Too bad Euphoria doesnt allow 'while (p=find(n,s))>0'
or it would shorten the routine even more:

--cant do this in euphoria?
while p=find(n,s) do
    s=s[1..p-1]&s[p+1..length(s)]
end while


Have fun with it!
--Al

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu