comparison lisp/cl-extra.el @ 5273:799742b751c8

Accept circular lists where that is useful in #'mapcar*, #'map* and friends. src/ChangeLog addition: 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * fns.c (Flist_length): New, moved here from cl-extra.el, needed by the next function. (shortest_length_among_sequences): New. (Fmapconcat, FmapcarX, Fmapvector, Fmapcan, Fmapc, Fmap) (Fmap_into, Fsome, Fevery): Use shortest_length_among_sequences() when working out how many iterations to do, only giving circular list errors if all arguments are circular.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 16 Sep 2010 20:34:49 +0100
parents 30bf66dd3ca0
children d27c1ee1943b 308d34e9f07d
comparison
equal deleted inserted replaced
5272:66dbef5f8076 5273:799742b751c8
402 (nconc (reverse x) y)) 402 (nconc (reverse x) y))
403 403
404 (defun nreconc (x y) 404 (defun nreconc (x y)
405 "Equivalent to (nconc (nreverse X) Y)." 405 "Equivalent to (nconc (nreverse X) Y)."
406 (nconc (nreverse x) y)) 406 (nconc (nreverse x) y))
407
408 (defun list-length (list)
409 "Return the length of LIST. Return nil if LIST is circular."
410 (if (listp list)
411 (condition-case nil (length list) (circular-list))
412 ;; Error on not-a-list:
413 (car list)))
414 407
415 (defun tailp (sublist list) 408 (defun tailp (sublist list)
416 "Return true if SUBLIST is a tail of LIST." 409 "Return true if SUBLIST is a tail of LIST."
417 (while (and (consp list) (not (eq sublist list))) 410 (while (and (consp list) (not (eq sublist list)))
418 (setq list (cdr list))) 411 (setq list (cdr list)))