Mercurial > emacs
annotate lisp/calc/calc-macs.el @ 62433:50ff61f0f99d
(define-minor-mode): Don't generate a defcustom for the mode hook variable.
author | Lute Kamstra <lute@gnu.org> |
---|---|
date | Tue, 17 May 2005 15:17:18 +0000 |
parents | d48ee50961f3 |
children | 842c8b2c2940 f2ebccfa87d4 |
rev | line source |
---|---|
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1 ;;; calc-macs.el --- important macros for Calc |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
2 |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40910
diff
changeset
|
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
4 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
5 ;; Author: David Gillespie <daveg@synaptics.com> |
58612
d48ee50961f3
Move provide to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
6 ;; Maintainer: Jay Belanger <belanger@truman.edu> |
40785 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is distributed in the hope that it will be useful, | |
11 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
12 ;; accepts responsibility to anyone for the consequences of using it | |
13 ;; or for whether it serves any particular purpose or works at all, | |
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
15 ;; License for full details. | |
16 | |
17 ;; Everyone is granted permission to copy, modify and redistribute | |
18 ;; GNU Emacs, but only under the conditions described in the | |
19 ;; GNU Emacs General Public License. A copy of this license is | |
20 ;; supposed to have been given to you along with GNU Emacs so you | |
21 ;; can know your rights and responsibilities. It should be in a | |
22 ;; file named COPYING. Among other things, the copyright notice | |
23 ;; and this notice must be preserved on all copies. | |
24 | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
25 ;;; Commentary: |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
26 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
27 ;;; Code: |
40785 | 28 |
29 (defmacro calc-wrapper (&rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
30 `(calc-do (function (lambda () |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
31 ,@body)))) |
40785 | 32 |
33 (defmacro calc-slow-wrapper (&rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
34 `(calc-do |
41341
6ab668229754
(calc-slow-wrapper): Move (point) call outside of (function ...)
Colin Walters <walters@gnu.org>
parents:
41266
diff
changeset
|
35 (function (lambda () ,@body)) (point))) |
40785 | 36 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
37 (defmacro math-showing-full-precision (form) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
38 `(let ((calc-float-format calc-full-float-format)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
39 ,form)) |
40785 | 40 |
41 (defmacro math-with-extra-prec (delta &rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
42 `(math-normalize |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
43 (let ((calc-internal-prec (+ calc-internal-prec ,delta))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
44 ,@body))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
45 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
46 (defmacro math-working (msg arg) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
47 `(if (eq calc-display-working-message 'lots) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
48 (math-do-working ,msg ,arg))) |
40785 | 49 |
43402
b7527fba7b15
(calc-with-default-simplification): Use &rest for body.
Colin Walters <walters@gnu.org>
parents:
41385
diff
changeset
|
50 (defmacro calc-with-default-simplification (&rest body) |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
51 `(let ((calc-simplify-mode (and (not (memq calc-simplify-mode '(none num))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
52 calc-simplify-mode))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
53 ,@body)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
54 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
55 (defmacro calc-with-trail-buffer (&rest body) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
56 `(let ((save-buf (current-buffer)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
57 (calc-command-flags nil)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
58 (with-current-buffer (calc-trail-display t) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
59 (progn |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
60 (goto-char calc-trail-pointer) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
61 ,@body)))) |
40785 | 62 |
63 ;;; Faster in-line version zerop, normalized values only. | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
64 (defsubst Math-zerop (a) ; [P N] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
65 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
66 (and (not (memq (car a) '(bigpos bigneg))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
67 (if (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
68 (eq (nth 1 a) 0) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
69 (math-zerop a))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
70 (eq a 0))) |
40785 | 71 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
72 (defsubst Math-integer-negp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
73 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
74 (eq (car a) 'bigneg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
75 (< a 0))) |
40785 | 76 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
77 (defsubst Math-integer-posp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
78 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
79 (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
80 (> a 0))) |
40785 | 81 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
82 (defsubst Math-negp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
83 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
84 (or (eq (car a) 'bigneg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
85 (and (not (eq (car a) 'bigpos)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
86 (if (memq (car a) '(frac float)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
87 (Math-integer-negp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
88 (math-negp a)))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
89 (< a 0))) |
40785 | 90 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
91 (defsubst Math-looks-negp (a) ; [P x] [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
92 (or (Math-negp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
93 (and (consp a) (or (eq (car a) 'neg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
94 (and (memq (car a) '(* /)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
95 (or (math-looks-negp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
96 (math-looks-negp (nth 2 a)))))))) |
40785 | 97 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
98 (defsubst Math-posp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
99 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
100 (or (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
101 (and (not (eq (car a) 'bigneg)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
102 (if (memq (car a) '(frac float)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
103 (Math-integer-posp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
104 (math-posp a)))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
105 (> a 0))) |
40785 | 106 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
107 (defsubst Math-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
108 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
109 (memq (car a) '(bigpos bigneg)))) |
40785 | 110 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
111 (defsubst Math-natnump (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
112 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
113 (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
114 (>= a 0))) |
40785 | 115 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
116 (defsubst Math-ratp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
117 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
118 (memq (car a) '(bigpos bigneg frac)))) |
40785 | 119 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
120 (defsubst Math-realp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
121 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
122 (memq (car a) '(bigpos bigneg frac float)))) |
40785 | 123 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
124 (defsubst Math-anglep (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
125 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
126 (memq (car a) '(bigpos bigneg frac float hms)))) |
40785 | 127 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
128 (defsubst Math-numberp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
129 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
130 (memq (car a) '(bigpos bigneg frac float cplx polar)))) |
40785 | 131 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
132 (defsubst Math-scalarp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
133 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
134 (memq (car a) '(bigpos bigneg frac float cplx polar hms)))) |
40785 | 135 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
136 (defsubst Math-vectorp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
137 (and (consp a) (eq (car a) 'vec))) |
40785 | 138 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
139 (defsubst Math-messy-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
140 (and (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
141 (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
142 (>= (nth 2 a) 0))) |
40785 | 143 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
144 (defsubst Math-objectp (a) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
145 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
146 (memq (car a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
147 '(bigpos bigneg frac float cplx polar hms date sdev intv mod)))) |
40785 | 148 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
149 (defsubst Math-objvecp (a) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
150 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
151 (memq (car a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
152 '(bigpos bigneg frac float cplx polar hms date |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
153 sdev intv mod vec)))) |
40785 | 154 |
155 ;;; Compute the negative of A. [O O; o o] [Public] | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
156 (defsubst Math-integer-neg (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
157 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
158 (if (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
159 (cons 'bigneg (cdr a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
160 (cons 'bigpos (cdr a))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
161 (- a))) |
40785 | 162 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
163 (defsubst Math-equal (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
164 (= (math-compare a b) 0)) |
40785 | 165 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
166 (defsubst Math-lessp (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
167 (= (math-compare a b) -1)) |
40785 | 168 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
169 (defsubst Math-primp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
170 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
171 (memq (car a) '(bigpos bigneg frac float cplx polar |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
172 hms date mod var)))) |
40785 | 173 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
174 (defsubst Math-num-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
175 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
176 (memq (car a) '(bigpos bigneg)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
177 (and (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
178 (>= (nth 2 a) 0)))) |
40785 | 179 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
180 (defsubst Math-bignum-test (a) ; [B N; B s; b b] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
181 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
182 a |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
183 (math-bignum a))) |
40785 | 184 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
185 (defsubst Math-equal-int (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
186 (or (eq a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
187 (and (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
188 (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
189 (eq (nth 1 a) b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
190 (= (nth 2 a) 0)))) |
40785 | 191 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
192 (defsubst Math-natnum-lessp (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
193 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
194 (and (consp b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
195 (= (math-compare-bignum (cdr a) (cdr b)) -1)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
196 (or (consp b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
197 (< a b)))) |
40785 | 198 |
58612
d48ee50961f3
Move provide to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
199 (provide 'calc-macs) |
d48ee50961f3
Move provide to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
200 |
52401 | 201 ;;; arch-tag: 08ba8ec2-fcff-4b80-a079-ec661bdb057e |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40910
diff
changeset
|
202 ;;; calc-macs.el ends here |