chickadee » srfi-14 » char-set-filter!

char-set-filter pred cs #!optional base-csprocedure
char-set-filter! pred cs base-csprocedure

Returns a character set containing every character C in CS such that (PRED C) returns true.

If character set BASE-CS is provided, the characters specified by PRED are added to it. char-set-filter! is allowed, but not required, to side-effect and reuse the storage in BASE-CS; char-set-filter produces a fresh character set.

An implementation may not save away a reference to PRED and invoke it after char-set-filter or char-set-filter! returns -- that is, "lazy," on-demand implementations are not allowed, as PRED may have external dependencies on mutable data or have other side-effects.

Rationale: This procedure provides a means of converting a character predicate into its equivalent character set; the CS parameter allows the programmer to bound the predicate's domain. Programmers should be aware that filtering a character set such as char-set:full could be a very expensive operation in an implementation that provided an extremely large character type, such as 32-bit Unicode. An earlier draft of this library provided a simple predicate->char-set procedure, which was rejected in favor of char-set-filter for this reason.