From 563d1d92f90f5e73f088eb42bf05b93903089ca0 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 29 Apr 2018 18:26:46 +0200 Subject: [PATCH] mes: Add string-map. * module/srfi/srfi-13.mes (string-map): New function. * tests/srfi-13.test ("string-map"): Test it. --- module/srfi/srfi-13.mes | 3 +++ tests/srfi-13.test | 3 +++ 2 files changed, 6 insertions(+) diff --git a/module/srfi/srfi-13.mes b/module/srfi/srfi-13.mes index 85db85e9..196e8f39 100644 --- a/module/srfi/srfi-13.mes +++ b/module/srfi/srfi-13.mes @@ -154,3 +154,6 @@ (define (string-trim-both string . pred) ((compose string-trim string-trim-right) string)) +(define (string-map f string) + (list->string (map f (string->list string)))) + diff --git a/tests/srfi-13.test b/tests/srfi-13.test index f9394db8..29035ccd 100755 --- a/tests/srfi-13.test +++ b/tests/srfi-13.test @@ -77,4 +77,7 @@ exit $? (pass-if-equal "string-trim-both" "foo" (string-trim-both " foo ")) +(pass-if-equal "string-map" "fuubar" + (string-map (lambda (c) (if (eq? c #\o) #\u c)) "foobar")) + (result 'report)