diff options
Diffstat (limited to 'lisp/calc/calc-misc.el')
-rw-r--r-- | lisp/calc/calc-misc.el | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/lisp/calc/calc-misc.el b/lisp/calc/calc-misc.el index aedb68726a5..d86b117c1f1 100644 --- a/lisp/calc/calc-misc.el +++ b/lisp/calc/calc-misc.el @@ -27,6 +27,7 @@ (require 'calc) (require 'calc-macs) +(require 'cl-lib) ;; Declare functions which are defined elsewhere. (declare-function calc-do-keypad "calc-keypd" (&optional full-display interactive)) @@ -116,14 +117,14 @@ Calc user interface as before (either C-x * C or C-x * K; initially C-x * C). (while (progn (message "Calc options: Calc, Keypad, ... %s" "press SPC, DEL to scroll, C-g to cancel") - (memq (car (setq key (calc-read-key t))) + (memq (setq key (read-event)) '(? ?\C-h ?\C-? ?\C-v ?\M-v))) - (condition-case err - (if (memq (car key) '(? ?\C-v)) + (condition-case nil + (if (memq key '(? ?\C-v)) (scroll-up) (scroll-down)) (error (beep)))) - (calc-unread-command (cdr key)))))) + (calc-unread-command key))))) (calc-do-dispatch nil)) (let ((calc-dispatch-help t)) (calc-do-dispatch arg)))) @@ -658,10 +659,7 @@ loaded and the keystroke automatically re-typed." ;;;###autoload (defun math-zerop (a) (if (consp a) - (cond ((memq (car a) '(bigpos bigneg)) - (while (eq (car (setq a (cdr a))) 0)) - (null a)) - ((memq (car a) '(frac float polar mod)) + (cond ((memq (car a) '(frac float polar mod)) (math-zerop (nth 1 a))) ((eq (car a) 'cplx) (and (math-zerop (nth 1 a)) (math-zerop (nth 2 a)))) @@ -677,9 +675,7 @@ loaded and the keystroke automatically re-typed." ;;;###autoload (defun math-negp (a) (if (consp a) - (cond ((eq (car a) 'bigpos) nil) - ((eq (car a) 'bigneg) (cdr a)) - ((memq (car a) '(float frac)) + (cond ((memq (car a) '(float frac)) (Math-integer-negp (nth 1 a))) ((eq (car a) 'hms) (if (math-zerop (nth 1 a)) @@ -712,9 +708,7 @@ loaded and the keystroke automatically re-typed." ;;;###autoload (defun math-posp (a) (if (consp a) - (cond ((eq (car a) 'bigpos) (cdr a)) - ((eq (car a) 'bigneg) nil) - ((memq (car a) '(float frac)) + (cond ((memq (car a) '(float frac)) (Math-integer-posp (nth 1 a))) ((eq (car a) 'hms) (if (math-zerop (nth 1 a)) @@ -734,36 +728,20 @@ loaded and the keystroke automatically re-typed." (> a 0))) ;;;###autoload -(defalias 'math-fixnump 'integerp) +(defalias 'math-fixnump #'fixnump) ;;;###autoload -(defalias 'math-fixnatnump 'natnump) - +(defun math-fixnatnump (x) (and (fixnump x) (natnump x))) ;; True if A is an even integer. [P R R] [Public] ;;;###autoload (defun math-evenp (a) - (if (consp a) - (and (memq (car a) '(bigpos bigneg)) - (= (% (nth 1 a) 2) 0)) - (= (% a 2) 0))) + (and (integerp a) (cl-evenp a))) ;; Compute A / 2, for small or big integer A. [I i] ;; If A is negative, type of truncation is undefined. ;;;###autoload (defun math-div2 (a) - (if (consp a) - (if (cdr a) - (math-normalize (cons (car a) (math-div2-bignum (cdr a)))) - 0) - (/ a 2))) - -;;;###autoload -(defun math-div2-bignum (a) ; [l l] - (if (cdr a) - (cons (+ (/ (car a) 2) (* (% (nth 1 a) 2) (/ math-bignum-digit-size 2))) - (math-div2-bignum (cdr a))) - (list (/ (car a) 2)))) - + (/ a 2)) ;; Reject an argument to a calculator function. [Public] ;;;###autoload |