Function: -split-when

-split-when is a byte-compiled function defined in dash.el.

Signature

(-split-when FN LIST)

Documentation

Split the LIST on each element where FN returns non-nil.

Unlike -partition-by, the "matched" element is discarded from the results. Empty lists are also removed from the result.

This function can be thought of as a generalization of split-string.

View in manual

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun -split-when (fn list)
  "Split the LIST on each element where FN returns non-nil.

Unlike `-partition-by', the \"matched\" element is discarded from
the results.  Empty lists are also removed from the result.

This function can be thought of as a generalization of
`split-string'."
  (declare (important-return-value t))
  (let (r s)
    (while list
      (if (not (funcall fn (car list)))
          (push (car list) s)
        (when s (push (nreverse s) r))
        (setq s nil))
      (!cdr list))
    (when s (push (nreverse s) r))
    (nreverse r)))