Elisp: Sequence Iteration, Conditional Exit
Foreach with Break, Get F Return Value
seq-some
-
Apply a function f to each sequence element in order, stop and return the first f result that's true. Else, return nil.
💡 TIP: This is useful as functional form of loop with break, especially if you want the return value of f.
;; demo of seq-some (seq-some (lambda (x) (if (eq 5 x) x nil )) [4 5 6]) ;; 5
Foreach with Break
seq-every-p
-
Apply a function f to each sequence element in order, return true if every result is true. As soon as a value is false, the loop stops.
💡 TIP: This is useful as functional form of loop with break, and you no need any return value.
;; demo of seq-every-p (seq-every-p (lambda (x) (if (eq (mod x 2) 0) x nil )) [4 5 6]) ;; nil
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 (seq-setq, seq-let)