diff options
Diffstat (limited to 'lisp/emacs-lisp/cl-seq.el')
-rw-r--r-- | lisp/emacs-lisp/cl-seq.el | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/cl-seq.el b/lisp/emacs-lisp/cl-seq.el index 31ad8111858..df3fbe89e95 100644 --- a/lisp/emacs-lisp/cl-seq.el +++ b/lisp/emacs-lisp/cl-seq.el @@ -113,6 +113,13 @@ (defvar cl-key) ;;;###autoload +(defun cl-endp (x) + "Return true if X is the empty list; false if it is a cons. +Signal an error if X is not a list." + (cl-check-type x list) + (null x)) + +;;;###autoload (defun cl-reduce (cl-func cl-seq &rest cl-keys) "Reduce two-argument FUNCTION across SEQ. \nKeywords supported: :start :end :from-end :initial-value :key @@ -122,9 +129,16 @@ second element of SEQ, then calling FUNCTION with that result and the third element of SEQ, then with that result and the fourth element of SEQ, etc. -If :INITIAL-VALUE is specified, it is added to the front of SEQ. -If SEQ is empty, return :INITIAL-VALUE and FUNCTION is not -called. +If :INITIAL-VALUE is specified, it is logically added to the +front of SEQ (or the back if :FROM-END is non-nil). If SEQ is +empty, return :INITIAL-VALUE and FUNCTION is not called. + +If SEQ is empty and no :INITIAL-VALUE is specified, then return +the result of calling FUNCTION with zero arguments. This is the +only case where FUNCTION is called with fewer than two arguments. + +If SEQ contains exactly one element and no :INITIAL-VALUE is +specified, then return that element and FUNCTION is not called. \n(fn FUNCTION SEQ [KEYWORD VALUE]...)" (cl--parsing-keywords (:from-end (:start 0) :end :initial-value :key) () @@ -696,9 +710,7 @@ Return the sublist of LIST whose car is ITEM. (while (and cl-list (not (cl--check-test cl-item (car cl-list)))) (setq cl-list (cdr cl-list))) cl-list) - (if (and (numberp cl-item) (not (integerp cl-item))) - (member cl-item cl-list) - (memq cl-item cl-list)))) + (memql cl-item cl-list))) (autoload 'cl--compiler-macro-member "cl-macs") ;;;###autoload @@ -737,7 +749,7 @@ Return the sublist of LIST whose car matches. (not (cl--check-test cl-item (car (car cl-alist)))))) (setq cl-alist (cdr cl-alist))) (and cl-alist (car cl-alist))) - (if (and (numberp cl-item) (not (integerp cl-item))) + (if (and (numberp cl-item) (not (fixnump cl-item))) (assoc cl-item cl-alist) (assq cl-item cl-alist)))) (autoload 'cl--compiler-macro-assoc "cl-macs") @@ -1033,7 +1045,6 @@ Atoms are compared by `eql'; cons cells are compared recursively. (run-hooks 'cl-seq-load-hook) ;; Local variables: -;; byte-compile-dynamic: t ;; generated-autoload-file: "cl-loaddefs.el" ;; End: |