Function: byte-opt--arith-reduce

byte-opt--arith-reduce is a byte-compiled function defined in byte-opt.el.gz.

Signature

(byte-opt--arith-reduce OP ACCUM ARGS)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/byte-opt.el.gz
;; Use OP to reduce any leading prefix of constant numbers in the list
;; (cons ACCUM ARGS) down to a single number, and return the
;; resulting list A of arguments.  The idea is that applying OP to A
;; is equivalent to (but likely more efficient than) applying OP to
;; (cons ACCUM ARGS), on any Emacs platform.  Do not make any special
;; provision for (- X) or (/ X); for example, it is the caller’s
;; responsibility that (- 1 0) should not be "optimized" to (- 1).
(defun byte-opt--arith-reduce (op accum args)
  (when (numberp accum)
    (let (accum1)
      (while (and (numberp (car args))
                  (numberp
                   (setq accum1 (condition-case ()
                                    (funcall op accum (car args))
                                  (error))))
                  (= accum1 (funcall op (float accum) (car args))))
        (setq accum accum1)
        (setq args (cdr args)))))
  (cons accum args))