From 3cbadcda86558227fbe357bd896d1d702a70663d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 26 Mar 2017 22:33:51 +0200 Subject: [PATCH] scm: Add list->char-set. * module/srfi/srfi-14.mes (list->char-set): New function. * tests/srfi-14.test ("list->char-set!"): Test it. --- module/srfi/srfi-14.mes | 3 +++ tests/srfi-14.test | 3 +++ 2 files changed, 6 insertions(+) diff --git a/module/srfi/srfi-14.mes b/module/srfi/srfi-14.mes index 6d383b6d..7287a4d5 100644 --- a/module/srfi/srfi-14.mes +++ b/module/srfi/srfi-14.mes @@ -37,6 +37,9 @@ (define char-set:whitespace (char-set #\tab #\return #\vtab #\newline #\space)) +(define (list->char-set lst) + (apply char-set lst)) + (define (string->char-set x . base) (apply char-set (append (string->list x) (if (null? base) '() (cdar base))))) diff --git a/tests/srfi-14.test b/tests/srfi-14.test index 97767240..a41db1a7 100755 --- a/tests/srfi-14.test +++ b/tests/srfi-14.test @@ -42,6 +42,9 @@ exit $? (pass-if "char-set-contains?" (char-set-contains? char-set:whitespace #\space)) +(pass-if "list->char-set!" + (char-set= (char-set #\a #\b #\c) (list->char-set '(#\a #\b #\c)))) + (pass-if "string->char-set!" (char-set= (char-set #\a #\b #\c #\d) (string->char-set! "d" (string->char-set "abc"))))