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
Emacs Lisp, Check Element Exist
Emacs Lisp, sequence functions
- Elisp: Sequence Type
- Elisp: Sequence Functions
- Elisp: Sequence. Take, Drop, Slice
- Elisp: Sequence. Iteration Guide
- Elisp: Sequence. Map
- Elisp: Sequence. Foreach
- Elisp: Sequence. some, every (conditional exit)
- Elisp: Sequence. Filter
- Elisp: Sequence. Insert or Remove
- Elisp: Sequence. Find
- Elisp: Sequence. Sort, Reverse
- Elisp: Sequence. Join, Convert
- Elisp: Sequence. Union, Intersection, Difference
- Elisp: Sequence. Partition, Group
- Elisp: Sequence. Min, Max, Random
- Elisp: Destructure Binding (seq-setq, seq-let)