Function: cl-list*

cl-list* is a byte-compiled function defined in cl-lib.el.gz.

Signature

(cl-list* ARG...)

Documentation

Return a new list with specified ARGs as elements, consed to last ARG.

Thus, (cl-list* A B C D) is equivalent to (nconc (list A B C) D), or to
(cons A (cons B (cons C D))).

View in manual

Aliases

list* (obsolete since 27.1)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-lib.el.gz
;;(defun last* (x &optional n)
;;  "Returns the last link in the list LIST.
;;With optional argument N, returns Nth-to-last link (default 1)."
;;  (if n
;;      (let ((m 0) (p x))
;;      (while (consp p) (incf m) (pop p))
;;	(if (<= n 0) p
;;	  (if (< n m) (nthcdr (- m n) x) x)))
;;    (while (consp (cdr x)) (pop x))
;;    x))

(defun cl-list* (arg &rest rest)
  "Return a new list with specified ARGs as elements, consed to last ARG.
Thus, `(cl-list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
`(cons A (cons B (cons C D)))'.
\n(fn ARG...)"
  (declare (side-effect-free error-free)
           (compiler-macro cl--compiler-macro-list*))
  (cond ((not rest) arg)
	((not (cdr rest)) (cons arg (car rest)))
	(t (let* ((n (length rest))
		  (copy (copy-sequence rest))
		  (last (nthcdr (- n 2) copy)))
	     (setcdr last (car (cdr last)))
	     (cons arg copy)))))