What boolean/logical convenience functions / macros are available for Emacs Lisp in either the core set of functions or external packages?
I'm interested in just about anything other than the built-in logical operators in
null) and conditional forms (
cond). To illustrate the sort of convenience functions I have in mind:
Common Lisp has sequence predicates such as
every and other functions like
count-if. When used with an identity function,
(some identity my-list) it performs a logical OR over elements in the list and
(every identity my-list) performs a logical AND over elements in the list. These are convenient and are nearly ideal, but aren't purely logical functions because they require a predicate that is applied to each element. These functions are available in
or conceptually fill the same niche, but clearly note that their use is limited because they are implemented as macros. Expressions such as
(apply and my-list) are not possible.
I have reviewed the list of ~1089 built-in Elisp functions and macros and only know of two relevant convenience functions.
booleanp checks if the argument's value is
not is an alias for
There are also numerous boolean vector convenience functions that are a part of Elisp, but as far as I can tell are only suitable for binary manipulation.
@Dan points out the use of
memq to search for nil values in a list can evaluate functions of logical values of a list using variations of
(memq nil my-list).
An example of a potential convenience function would be a boolean identity function that simply converts a value to its canonical boolean form.
(defun boolean-identity (x) (if x t nil))