mes: Add char-set-adjoin, char-set-complement.

* mes/module/srfi/srfi-14.mes (char-set-adjoin, char-set-complement):
New function.
This commit is contained in:
Jan Nieuwenhuizen 2018-11-11 10:08:03 +01:00
parent 1f1fa33eaa
commit b9534cb287
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -47,9 +47,16 @@
(set-cdr! (last-pair base) (string->list x))
base)
(define (char-set-adjoin cs . chars)
(append cs chars))
(define (char-set-contains? cs x)
(and (memq x cs) #t))
(define (char-set-complement cs)
(let ((ascii (map integer->char (iota 128))))
(list->char-set (filter (lambda (c) (not (char-set-contains? cs c))) ascii))))
(define (char-whitespace? c)
(char-set-contains? char-set:whitespace c))