Created
October 1, 2012 12:48
-
-
Save lambdaman2/3811578 to your computer and use it in GitHub Desktop.
Scheme: scheme: replace a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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"))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment