Mercurial > emacs
comparison lisp/subr.el @ 110972:dff76f22a051
lisp/subr.el (last): Deal with dotted lists (reported in bug#7174).
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Thu, 14 Oct 2010 01:43:39 +0200 |
parents | 80846b446563 |
children | bad40b05a0df |
comparison
equal
deleted
inserted
replaced
110971:80846b446563 | 110972:dff76f22a051 |
---|---|
287 "Return the last link of LIST. Its car is the last element. | 287 "Return the last link of LIST. Its car is the last element. |
288 If LIST is nil, return nil. | 288 If LIST is nil, return nil. |
289 If N is non-nil, return the Nth-to-last link of LIST. | 289 If N is non-nil, return the Nth-to-last link of LIST. |
290 If N is bigger than the length of LIST, return LIST." | 290 If N is bigger than the length of LIST, return LIST." |
291 (if n | 291 (if n |
292 (and (> n 0) | 292 (and (>= n 0) |
293 (let ((m (safe-length list))) | 293 (let ((m (safe-length list))) |
294 (if (< n m) (nthcdr (- m n) list) list))) | 294 (if (< n m) (nthcdr (- m n) list) list))) |
295 (and list | 295 (and list |
296 (nthcdr (1- (safe-length list)) list)))) | 296 (nthcdr (1- (safe-length list)) list)))) |
297 | 297 |