/ Published in: Scheme

Written for the impromptu-scheme environment.. other schemes might need different procedures..
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(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")))))
Comments
