Optimized string-replace function
Hello,I am using a home-made string-replace function over large strings.
This is not efficient and my program runs "forever".
Where can I find an efficient one for Lispworks?
Does Lispworks includes one of it own?
This is the function I use:
;This function was taken from
(defun string-replace (str1 sub1 sub2)
(let ((str1 (string str1))
(str2 "")
(sub1 (string sub1))
(sub2 (string sub2))
(index1 0))
(loop
(if (string-equal str1 sub1
:start1 index1
:end1 (min (length str1)
(+ index1 (length sub1))))
(progn
(setq str2 (concatenate 'string str2 sub2))
(incf index1 (length sub1)))
(progn
(setq str2 (concatenate 'string
str2
(subseq str1 index1 (1+ index1))))
(incf index1)))
(unless (< index1 (length str1))
(return str2)))))
Thank you,
Mauricio
--
Mauricio TORO BERMUDEZ
Research Postgraduate Student (Ph.D)
Computer Science Research Laboratory of Bordeaux (LABRI)
University of Bordeaux 1: Science and Technology
http://www.labri.fr/perso/mtoro/
351, cours de la Libération
F-33405 Talence Cedex. France.
Phone: (+33) 5 4000 24 85
Fax: (+33) 5 4000 66 69
Please don't print this e-mail unless you really need to.