Skip to content

Instantly share code, notes, and snippets.

@lambdaman2
Created October 1, 2012 12:48
Show Gist options
  • Save lambdaman2/3811578 to your computer and use it in GitHub Desktop.
Save lambdaman2/3811578 to your computer and use it in GitHub Desktop.
Scheme: scheme: replace a string
(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