New answers tagged

2

How about this? (defun or-list (list) (cl-some #'identity list)) Here cl-some takes two arguments: a predicate and a list and returns non-nil if the predicate applied to some member of the list is non-nil. In our case, the identity function is a good predicate since we only want to test whether our list members are themselves non-nil.


3

If you wanted this for a function you would use apply, but as or is a special form you can't do that. In particular, or only evaluates as many arguments as it needs to. You could write a macro: (defmacro or-list (list) `(or ,@(eval list))) (setq mylist '(a b c)) (or-list mylist) then expands to (or a b c)


Top 50 recent answers are included