Elisp: Sequence Find
Check If Item Exist
seq-contains
-
(seq-contains SEQUENCE ELT &optional TESTFN)
check if item exist by equality test. 〔see Elisp: Equality Test〕
(seq-contains [3 4 5] 5 ) ;; 5
seq-position
-
(seq-position SEQUENCE ELT &optional TESTFN)
return the position of the first occurrence, if exist.
(seq-position [3 4 5 4] 4 ) ;; 1
seq-positions
-
(seq-positions SEQUENCE ELT &optional TESTFN)
check if item exist by equality test, and return a list of positions.
(seq-positions [3 4 5 4] 4 ) ;; (1 3)
Find by Criterion, Count
seq-find
-
(seq-find PRED SEQUENCE &optional DEFAULT)
return first item a function returns true.
(setq xx [ "once" "upon" "a" "time" ]) (seq-find (lambda (x) (string-match "p" x)) xx) ;; "upon"
seq-count
-
(seq-find PRED SEQUENCE &optional DEFAULT)
return count where a function return true.
(setq xx [ "once" "upon" "a" "time" ]) (seq-count (lambda (x) (string-match "e" x)) xx) ;; 2
Elisp, Check Element Exist
Elisp, sequence functions
- Elisp: Sequence Type
- Elisp: Sequence Functions
- Elisp: Sequence, Take, Drop, Slice
- Elisp: Map to Sequence
- Elisp: Foreach (Side-Effect)
- Elisp: Sequence Iteration, Conditional Exit
- Elisp: Sequence Filter
- Elisp: Sequence Map Insert
- Elisp: Sequence Iteration
- Elisp: Sequence Find
- Elisp: Sequence, Sort, Reverse
- Elisp: Sequence Join, Convert
- Elisp: Sequence Union, Intersection, Difference
- Elisp: More Sequence Functions
- Elisp: Destructure Binding