(last): New function.
authorRichard M. Stallman <rms@gnu.org>
Sat, 23 Aug 1997 19:10:42 +0000 (19:10 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 23 Aug 1997 19:10:42 +0000 (19:10 +0000)
lisp/subr.el

index a93cd3f..513a63a 100644 (file)
@@ -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)
 \f
 ;;;; Keymap support.