Allow (count:) to accept multiple values
Currently, (count:) is essentially a slightly different contains
operator - returning a number instead of a boolean. Also, both are limited by the fact that they can only check for one item's presence - you can't do contains ...$vals
, and you can't do (count: ...$vals)
.
(count:) can be easily expanded to cope with multiple values - its signature will be (count: Any, [...Any])
. It would return the sum of occurrences of each of the values. It would also be altered to apply to datamaps and datasets (as they would no longer necessarily always return 1 or 0). As a result, one could modify (count:) to check for the unique presence of values by wrapping the container in either (datanames:) (for datamaps) or (dataset:) (for arrays), to filter for unique values.
An aside: originally, I'd envisioned the reverse expansion of (count:) - it would accept one value, and you could supply a sequence to it. This is no longer practical due to the current signature of (count:) explicitly accepting a collection, in first position. And, it would essentially be a re-phrasing of the current state of (count:) in terms of semantics.
Question: similar "data structure query" macros are (datanames:) and (datavalues:). Should they be expanded to be variadic, accepting multiple datamaps?
Other question: should there be a (contains-all:) macro, which can provide a more convenient check that every value is in the given container? Or maybe that should be a new contains all
operator?