I'm trying to apply a logic function over a list, but:
e.g.(apply 'and some_list)
give me Invalid function: and
.
There is a way to apply a logical function to a list?
I'm trying to apply a logic function over a list, but:
e.g.(apply 'and some_list)
give me Invalid function: and
.
There is a way to apply a logical function to a list?
This is because and
is not a function (it is a special form).
Note that C-h f and
tells you "and is a special form in `C source code'."
apply
must be used with a function.
The manual says:
‘apply’ returns the result of calling FUNCTION. As with ‘funcall’, FUNCTION must either be a Lisp function or a primitive function; special forms and macros do not make sense in ‘apply’.
and
as a function -- functions evaluate all of their arguments, whereas macros and special forms receive their arguments un-evaluated (which is necessary for and
, which must not evaluate the remaining arguments if it has already failed).
– phils
Oct 15 '18 at 21:52
and
you have (cl-every #'identity some_list)
and for or
you have (cl-some #'identity some_list)
.
– Tobias
Oct 15 '18 at 21:59
(memq nil LIST)
will tell you if any of the list elements is nil
.
– phils
Oct 15 '18 at 21:59
C-h f apply
..... – Drew Oct 15 '18 at 22:48