This is like `equal', except that it accepts numerically equal
numbers of different types (float vs. integer), and also compares
strings case-insensitively."
+ (declare (side-effect-free error-free))
(cond ((eq x y) t)
((stringp x)
(and (stringp y) (string-equal-ignore-case x y)))
;;;###autoload
(defun cl-gcd (&rest args)
"Return the greatest common divisor of the arguments."
+ (declare (side-effect-free t))
(let ((a (or (pop args) 0)))
(dolist (b args)
(while (/= b 0)
;;;###autoload
(defun cl-lcm (&rest args)
"Return the least common multiple of the arguments."
+ (declare (side-effect-free t))
(if (memq 0 args)
0
(let ((a (or (pop args) 1)))
;;;###autoload
(defun cl-isqrt (x)
"Return the integer square root of the (integer) argument X."
+ (declare (side-effect-free t))
(if (and (integerp x) (> x 0))
(let ((g (ash 2 (/ (logb x) 2)))
g2)
(defun cl-floor (x &optional y)
"Return a list of the floor of X and the fractional part of X.
With two arguments, return floor and remainder of their quotient."
+ (declare (side-effect-free t))
(let ((q (floor x y)))
(list q (- x (if y (* y q) q)))))
(defun cl-ceiling (x &optional y)
"Return a list of the ceiling of X and the fractional part of X.
With two arguments, return ceiling and remainder of their quotient."
+ (declare (side-effect-free t))
(let ((res (cl-floor x y)))
(if (= (car (cdr res)) 0) res
(list (1+ (car res)) (- (car (cdr res)) (or y 1))))))
(defun cl-truncate (x &optional y)
"Return a list of the integer part of X and the fractional part of X.
With two arguments, return truncation and remainder of their quotient."
+ (declare (side-effect-free t))
(if (eq (>= x 0) (or (null y) (>= y 0)))
(cl-floor x y) (cl-ceiling x y)))
(defun cl-round (x &optional y)
"Return a list of X rounded to the nearest integer and the remainder.
With two arguments, return rounding and remainder of their quotient."
+ (declare (side-effect-free t))
(if y
(if (and (integerp x) (integerp y))
(let* ((hy (/ y 2))
;;;###autoload
(defun cl-mod (x y)
"The remainder of X divided by Y, with the same sign as Y."
+ (declare (side-effect-free t))
(nth 1 (cl-floor x y)))
;;;###autoload
(defun cl-rem (x y)
"The remainder of X divided by Y, with the same sign as X."
+ (declare (side-effect-free t))
(nth 1 (cl-truncate x y)))
;;;###autoload
(defun cl-signum (x)
"Return 1 if X is positive, -1 if negative, 0 if zero."
+ (declare (side-effect-free t))
(cond ((> x 0) 1) ((< x 0) -1) (t 0)))
;;;###autoload
;; Random numbers.
(defun cl--random-time ()
- "Return high-precision timestamp from `time-convert'.
+ "Return high-precision timestamp from `time-convert'.
For example, suitable for use as seed by `cl-make-random-state'."
- (car (time-convert nil t)))
+ (car (time-convert nil t)))
;;;###autoload (autoload 'cl-random-state-p "cl-extra")
+;;;###autoload (function-put 'cl-random-state-p 'side-effect-free 'error-free)
(cl-defstruct (cl--random-state
(:copier nil)
(:predicate cl-random-state-p)
If START or END is negative, it counts from the end.
Signal an error if START or END are outside of the sequence (i.e
too large if positive or too small if negative)."
+ (declare (side-effect-free t))
(declare (gv-setter
(lambda (new)
(macroexp-let2 nil new new
;;;###autoload
(defun cl-list-length (x)
"Return the length of list X. Return nil if list is circular."
+ (declare (side-effect-free t))
(cl-check-type x list)
(condition-case nil
(length x)
(defun cl-get (sym tag &optional def)
"Return the value of SYMBOL's PROPNAME property, or DEFAULT if none.
\n(fn SYMBOL PROPNAME &optional DEFAULT)"
- (declare (compiler-macro cl--compiler-macro-get)
+ (declare (side-effect-free t)
+ (compiler-macro cl--compiler-macro-get)
(gv-setter (lambda (store) (ignore def) `(put ,sym ,tag ,store))))
(cl-getf (symbol-plist sym) tag def))
(autoload 'cl--compiler-macro-get "cl-macs")
"Search PROPLIST for property PROPNAME; return its value or DEFAULT.
PROPLIST is a list of the sort returned by `symbol-plist'.
\n(fn PROPLIST PROPNAME &optional DEFAULT)"
- (declare (gv-expander
+ (declare (side-effect-free t)
+ (gv-expander
(lambda (do)
(gv-letplace (getter setter) plist
(macroexp-let2* nil ((k tag) (d def))
(defsubst cl-plusp (number)
"Return t if NUMBER is positive."
+ (declare (side-effect-free t))
(> number 0))
(defsubst cl-minusp (number)
"Return t if NUMBER is negative."
+ (declare (side-effect-free t))
(< number 0))
(defalias 'cl-oddp 'oddp)
(defsubst cl-fifth (x)
"Return the fifth element of the list X."
- (declare (gv-setter (lambda (store) `(setcar (nthcdr 4 ,x) ,store))))
+ (declare (side-effect-free t)
+ (gv-setter (lambda (store) `(setcar (nthcdr 4 ,x) ,store))))
(nth 4 x))
(defsubst cl-sixth (x)
"Return the sixth element of the list X."
- (declare (gv-setter (lambda (store) `(setcar (nthcdr 5 ,x) ,store))))
+ (declare (side-effect-free t)
+ (gv-setter (lambda (store) `(setcar (nthcdr 5 ,x) ,store))))
(nth 5 x))
(defsubst cl-seventh (x)
"Return the seventh element of the list X."
- (declare (gv-setter (lambda (store) `(setcar (nthcdr 6 ,x) ,store))))
+ (declare (side-effect-free t)
+ (gv-setter (lambda (store) `(setcar (nthcdr 6 ,x) ,store))))
(nth 6 x))
(defsubst cl-eighth (x)
"Return the eighth element of the list X."
- (declare (gv-setter (lambda (store) `(setcar (nthcdr 7 ,x) ,store))))
+ (declare (side-effect-free t)
+ (gv-setter (lambda (store) `(setcar (nthcdr 7 ,x) ,store))))
(nth 7 x))
(defsubst cl-ninth (x)
"Return the ninth element of the list X."
- (declare (gv-setter (lambda (store) `(setcar (nthcdr 8 ,x) ,store))))
+ (declare (side-effect-free t)
+ (gv-setter (lambda (store) `(setcar (nthcdr 8 ,x) ,store))))
(nth 8 x))
(defsubst cl-tenth (x)
"Return the tenth element of the list X."
- (declare (gv-setter (lambda (store) `(setcar (nthcdr 9 ,x) ,store))))
+ (declare (side-effect-free t)
+ (gv-setter (lambda (store) `(setcar (nthcdr 9 ,x) ,store))))
(nth 9 x))
(defalias 'cl-caaar #'caaar)
Thus, `(cl-list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
`(cons A (cons B (cons C D)))'.
\n(fn ARG...)"
- (declare (compiler-macro cl--compiler-macro-list*))
+ (declare (side-effect-free error-free)
+ (compiler-macro cl--compiler-macro-list*))
(cond ((not rest) arg)
((not (cdr rest)) (cons arg (car rest)))
(t (let* ((n (length rest))
(defun cl-ldiff (list sublist)
"Return a copy of LIST with the tail SUBLIST removed."
+ (declare (side-effect-free t))
(let ((res nil))
(while (and (consp list) (not (eq list sublist)))
(push (pop list) res))
(defun cl-acons (key value alist)
"Add KEY and VALUE to ALIST.
Return a new list with (cons KEY VALUE) as car and ALIST as cdr."
+ (declare (side-effect-free error-free))
(cons (cons key value) alist))
(defun cl-pairlis (keys values &optional alist)
Return a new alist composed by associating KEYS to corresponding VALUES;
the process stops as soon as KEYS or VALUES run out.
If ALIST is non-nil, the new pairs are prepended to it."
+ (declare (side-effect-free t))
(nconc (cl-mapcar 'cons keys values) alist))
;;; Miscellaneous.