Function: -map-first

-map-first is a byte-compiled function defined in dash.el.

Signature

(-map-first PRED REP LIST)

Documentation

Use PRED to determine the first item in LIST to call REP on.

Return a copy of LIST where the first item for which PRED returns non-nil is replaced with the result of calling REP on that item.

See also: -map-when, -replace-first

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun -map-first (pred rep list)
  "Use PRED to determine the first item in LIST to call REP on.
Return a copy of LIST where the first item for which PRED returns
non-nil is replaced with the result of calling REP on that item.

See also: `-map-when', `-replace-first'"
  (declare (important-return-value t))
  (let (front)
    (while (and list (not (funcall pred (car list))))
      (push (car list) front)
      (!cdr list))
    (if list
        (-concat (nreverse front) (cons (funcall rep (car list)) (cdr list)))
      (nreverse front))))