Function: take

take is a byte-compiled function defined in compat-29.el.

Signature

(take N LIST)

Documentation

[Compatibility function for take, defined in Emacs 29.1. See (compat) Emacs
29.1' for more details.]

Return the first N elements of LIST. If N is zero or negative, return nil. If N is greater or equal to the length of LIST, return LIST (or a copy).

Probably introduced at or before Emacs version 1.4.

Source Code

;; Defined in ~/.emacs.d/elpa/compat-30.1.0.1/compat-29.el
(compat-defun take (n list) ;; <compat-tests:take>
  "Return the first N elements of LIST.
If N is zero or negative, return nil.
If N is greater or equal to the length of LIST, return LIST (or a copy)."
  (declare (pure t) (side-effect-free t))
  (let (copy)
    (while (and (< 0 n) list)
      (push (pop list) copy)
      (setq n (1- n)))
    (nreverse copy)))