Hi again,
I have implemented longssubst which
does what ssubst does and works on strings
larger than 5 kilobytes.
Unfortanately my code is much slower.
Could someone tell me why?
longssubst(nsub,osub,str) :=
block([out,len,nlen,olen,item,i],
len : slength(str),
nlen : slength(nsub),
olen : slength(osub),
out : "",
for i : 1 thru len-(olen-1) do
(
item : substring(str,i,i+olen),
if item=osub then
(
out : concat(out,nsub),
i : i + olen-1
)
else
(
out : concat(out,substring(str,i,i+1))
)
),
for i : len-(olen-1)+1 thru len do
(
out : concat(out,substring(str,i,i+1))
),
return(out)
);
Fabrizio