Return to Snippet

Revision: 23740
at February 12, 2010 01:23 by magicrebirth


Initial Code
(define string-replace 
   (lambda (s match replacement)
      (let ((ll (string->list s))
            (match1 (char match))
            (replacement1 (char replacement)))
         (if (= (string-length match) 1)
             (let ((z (map (lambda (x)
                              (if (equal? x match1)
                                  replacement1
                                  x))
                           ll)))
                (list->string (list-flatten z)))
                ;z)
             (print "i can match only single characters for now")))))

Initial URL

                                

Initial Description
Written for the impromptu-scheme environment.. other schemes might need different  procedures..

Initial Title
scheme: replace a string

Initial Tags

                                

Initial Language
Scheme