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 (cl-func cl-list &rest cl-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...)"
  (if cl-rest
      (let ((cl-res nil)
	    (cl-args (cons cl-list (copy-sequence cl-rest)))
	    cl-p)
	(while (not (memq nil cl-args))
	  (push (apply cl-func cl-args) cl-res)
	  (setq cl-p cl-args)
	  (while cl-p (setcar cl-p (cdr (pop cl-p)))))
	(nreverse cl-res))
    (let ((cl-res nil))
      (while cl-list
	(push (funcall cl-func cl-list) cl-res)
	(setq cl-list (cdr cl-list)))
      (nreverse cl-res))))