Function: last
last is a byte-compiled function defined in subr.el.gz.
Signature
(last LIST &optional N)
Documentation
Return the last link of LIST. Its car is the last element.
If LIST is nil, return nil. If N is non-nil, return the Nth-to-last link of LIST. If N is bigger than the length of LIST, return LIST.
Other relevant functions are documented in the list group.
Shortdoc
;; list
(last '(one two three))
=> (three)
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun last (list &optional n)
"Return the last link of LIST. Its car is the last element.
If LIST is nil, return nil.
If N is non-nil, return the Nth-to-last link of LIST.
If N is bigger than the length of LIST, return LIST."
(declare (side-effect-free t))
(if n
(and (>= n 0)
(let ((m (safe-length list)))
(if (< n m) (nthcdr (- m n) list) list)))
(and list
(nthcdr (1- (safe-length list)) list))))