scm: Add list->char-set.

* module/srfi/srfi-14.mes (list->char-set): New function.
* tests/srfi-14.test ("list->char-set!"): Test it.
This commit is contained in:
Jan Nieuwenhuizen 2017-03-26 22:33:51 +02:00
parent 408696f380
commit 3cbadcda86
2 changed files with 6 additions and 0 deletions

View file

@ -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)))))

View file

@ -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"))))