From e8c32c9941ea6d9c7ae11964140a97a9e0567309 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sat, 23 Aug 1997 19:10:42 +0000 Subject: [PATCH] (last): New function. --- lisp/subr.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lisp/subr.el b/lisp/subr.el index a93cd3f8b52..513a63a2f21 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -78,6 +78,13 @@ BODY should be a list of lisp expressions." (defsubst cddr (x) "Return the cdr of the cdr of X." (cdr (cdr x))) + +(defun last (x) + "Return the last element of the list X. +If X is nil, return nil." + (while (cdr x) + (setq x (cdr x))) + x) ;;;; Keymap support. -- 2.39.2