6.9 Miscellaneous Functions

FSet exports a few ordinary functions. They’re not CLOS generic functions, but they’re applicable to many types anyway because they invoke generic functions.

Function: nonempty? x

Returns (not (empty? x)).

Function: member? x coll

Returns (contains? coll x). Personally, I prefer contains? because it puts the collection first, as do many other FSet operations, but you might like member? because cl:member puts the collection second.

Function: some pred sequence0 &rest more-sequences
Function: every pred sequence0 &rest more-sequences
Function: notany pred sequence0 &rest more-sequences
Function: notevery pred sequence0 &rest more-sequences

These generalize the CL builtins of the same names. They accept any CL sequence as well as an FSet set or sequence. (They use iterator to obtain an iterator over each operand sequence.)

Function: updated fn coll &rest keys
Function: update fn coll &rest keys

Returns a new version of collection coll in which the element reached by doing chained lookups on keys is updated by calling fn on it. For example, instead of writing

(incf ( ( ( foo 'a) 3) "xyzzy"))

you can write, equivalently

(setq foo (updated #'1+ foo 'a 3 "xyzzy"))

This is probably most useful in contexts where you don’t want to do the setq anyway, perhaps because you’re passing the result as an argument. fn can be a function object, an fbound symbol, or a map.

(For most of FSet’s existence, this has been called update, but I recently decided that name is too suggestive of mutation, and have deprecated it in favor of updated.)