Predicates
Reductions of one or more lists to a boolean value.
Function: -some (pred list)
Return (pred x) for the first list item where (pred x) is non-nil, else nil.
Alias: -any.
This function’s anaphoric counterpart is --some.
(-some #'stringp '(1 "2" 3))
⇒ t(--some (string-match-p "x" it) '("foo" "axe" "xor"))
⇒ 1(--some (= it-index 3) '(0 1 2))
⇒ nilFunction: -every (pred list)
Return non-nil if pred returns non-nil for all items in list. If so, return the last such result of pred. Otherwise, once an item is reached for which pred returns nil, return nil without calling pred on any further list elements.
This function is like -every-p, but on success returns the last non-nil result of pred instead of just t.
This function’s anaphoric counterpart is --every.
(-every #'numberp '(1 2 3))
⇒ t(--every (string-match-p "x" it) '("axe" "xor"))
⇒ 0(--every (= it it-index) '(0 1 3))
⇒ nilFunction: -any? (pred list)
Return t if (pred x) is non-nil for any x in list, else nil.
Alias: -any-p, -some?, -some-p
(-any? #'numberp '(nil 0 t))
⇒ t(-any? #'numberp '(nil t t))
⇒ nil(-any? #'null '(1 3 5))
⇒ nilFunction: -all? (pred list)
Return t if (pred x) is non-nil for all x in list, else nil. In the latter case, stop after the first x for which (pred x) is nil, without calling pred on any subsequent elements of list.
The similar function -every (see -every) is more widely useful, since it returns the last non-nil result of pred instead of just t on success.
Alias: -all-p, -every-p, -every?.
This function’s anaphoric counterpart is --all?.
(-all? #'numberp '(1 2 3))
⇒ t(-all? #'numberp '(2 t 6))
⇒ nil(--all? (= 0 (% it 2)) '(2 4 6))
⇒ tFunction: -none? (pred list)
Return t if (pred x) is nil for all x in list, else nil.
Alias: -none-p
(-none? 'even? '(1 2 3))
⇒ nil(-none? 'even? '(1 3 5))
⇒ t(--none? (= 0 (% it 2)) '(1 2 3))
⇒ nilFunction: -only-some? (pred list)
Return t if different list items both satisfy and do not satisfy pred. That is, if pred returns both nil for at least one item, and non-nil for at least one other item in list. Return nil if all items satisfy the predicate or none of them do.
Alias: -only-some-p
(-only-some? 'even? '(1 2 3))
⇒ t(-only-some? 'even? '(1 3 5))
⇒ nil(-only-some? 'even? '(2 4 6))
⇒ nilFunction: -contains? (list element)
Return non-nil if list contains element.
The test for equality is done with equal, or with -compare-fn if that is non-nil. As with member, the return value is actually the tail of list whose car is element.
Alias: -contains-p.
(-contains? '(1 2 3) 1)
⇒ (1 2 3)(-contains? '(1 2 3) 2)
⇒ (2 3)(-contains? '(1 2 3) 4)
⇒ ()Function: -is-prefix? (prefix list)
Return non-nil if prefix is a prefix of list.
Alias: -is-prefix-p.
(-is-prefix? '(1 2 3) '(1 2 3 4 5))
⇒ t(-is-prefix? '(1 2 3 4 5) '(1 2 3))
⇒ nil(-is-prefix? '(1 3) '(1 2 3 4 5))
⇒ nilFunction: -is-suffix? (suffix list)
Return non-nil if suffix is a suffix of list.
Alias: -is-suffix-p.
(-is-suffix? '(3 4 5) '(1 2 3 4 5))
⇒ t(-is-suffix? '(1 2 3 4 5) '(3 4 5))
⇒ nil(-is-suffix? '(3 5) '(1 2 3 4 5))
⇒ nilFunction: -is-infix? (infix list)
Return non-nil if infix is infix of list.
This operation runs in o(n^2) time
Alias: -is-infix-p
(-is-infix? '(1 2 3) '(1 2 3 4 5))
⇒ t(-is-infix? '(2 3 4) '(1 2 3 4 5))
⇒ t(-is-infix? '(3 4 5) '(1 2 3 4 5))
⇒ tFunction: -cons-pair? (obj)
Return non-nil if obj is a true cons pair. That is, a cons (a . b) where b is not a list.
Alias: -cons-pair-p.
(-cons-pair? '(1 . 2))
⇒ t(-cons-pair? '(1 2))
⇒ nil(-cons-pair? '(1))
⇒ nil