Function: cl-maplist

cl-maplist is an autoloaded and byte-compiled function defined in cl-extra.el.gz.

Signature

(cl-maplist FUNCTION LIST...)

Documentation

Map FUNCTION to each sublist of LIST or LISTs.

Like cl-mapcar, except applies to lists and their cdr's rather than to the elements themselves.

View in manual

Aliases

maplist (obsolete since 27.1)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-extra.el.gz
;;;###autoload
(defun cl-maplist (func list &rest rest)
  "Map FUNCTION to each sublist of LIST or LISTs.
Like `cl-mapcar', except applies to lists and their cdr's rather than to
the elements themselves.
\n(fn FUNCTION LIST...)"
  (declare (important-return-value t))
  (if rest
      (let ((res nil)
            (args (cons list (copy-sequence rest)))
            p)
        (while (not (memq nil args))
          (push (apply func args) res)
          (setq p args)
          (while p (setcar p (cdr (pop p)))))
        (nreverse res))
    (let ((res nil))
      (while list
        (push (funcall func list) res)
        (setq list (cdr list)))
      (nreverse res))))