Next: , Previous: , Up: srfi char-sets spec   [Index]


2.9.3.6 Character set algebra

Function: char-set-adjoin cs char ...
Function: char-set-delete cs char ...

Add/delete the char characters to/from character set cs.

Function: char-set-adjoin! cs char ...
Function: char-set-delete! cs char ...

Linear–update variants. These procedures are allowed, but not required, to side–effect their first parameter.

Function: char-set-complement cs
Function: char-set-union cs ...
Function: char-set-intersection cs ...
Function: char-set-difference cs0 cs ...
Function: char-set-xor cs ...
Function: char-set-diff+intersection cs0 cs ...

These procedures implement set complement, union, intersection, difference, and exclusive OR for character sets. The union, intersection and xor operations are n–ary. The difference function is also n–ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.

(char-set-difference (char-set #\a)
                     (char-set #\b))
⇒ (char-set #\a)

Boundary cases:

(char-set-union)                ⇒ char-set:empty
(char-set-intersection)         ⇒ char-set:full
(char-set-xor)                  ⇒ char-set:empty
(char-set-difference cs)        ⇒ cs

char-set-diff+intersection returns two values: the difference and the intersection of the arguments; it partitions its first argument. It is almost equivalent to:

(values (char-set-difference cs1 cs2 ...)
        (char-set-intersection cs1 (char-set-union cs2 ...)))

but can be implemented more efficiently; when called with one argument: the first return value is a copy of the argument itself, the second return value is the empty set.

Function: char-set-complement! cs
Function: char-set-union! cs0 cs ...
Function: char-set-intersection! cs0 cs ...
Function: char-set-difference! cs0 cs ...
Function: char-set-xor! cs0 cs ...
Function: char-set-diff+intersection! cs0 cs1 cs ...

These are linear–update variants of the set–algebra functions. They are allowed, but not required, to side–effect their first (required) argument.

char-set-diff+intersection! is allowed to side–effect both of its two required arguments.


Next: , Previous: , Up: srfi char-sets spec   [Index]