Mercurial > emacs
annotate lisp/calc/calc-macs.el @ 112214:40a246eebab9
* lisp/emacs-lisp/easymenu.el: Add :enable, and obey :label. Require CL.
(easy-menu-create-menu, easy-menu-convert-item-1):
Use :label rather than nil for labels. Use `case'.
Add :enable as alias for :active.
(easy-menu-binding): Obey :label.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 13 Jan 2011 21:12:43 -0500 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
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 |
64325
1db49616ce05
Update copyright information.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
62442
diff
changeset
|
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
5 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
6 ;; Author: David Gillespie <daveg@synaptics.com> |
77465
1154f082efd9
Update maintainer's address.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
76595
diff
changeset
|
7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> |
40785 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
94654
6c9af2bfcfee
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
76595
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
94654
6c9af2bfcfee
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
6c9af2bfcfee
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
40785 | 15 |
76595
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
19 ;; GNU General Public License for more details. |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
20 |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
94654
6c9af2bfcfee
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
40785 | 23 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
24 ;;; Commentary: |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
25 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
26 ;;; Code: |
40785 | 27 |
86476
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
28 ;; Declare functions which are defined elsewhere. |
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
29 (declare-function math-zerop "calc-misc" (a)) |
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
30 (declare-function math-negp "calc-misc" (a)) |
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
31 (declare-function math-looks-negp "calc-misc" (a)) |
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
32 (declare-function math-posp "calc-misc" (a)) |
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
33 (declare-function math-compare "calc-ext" (a b)) |
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
34 (declare-function math-bignum "calc" (a)) |
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
35 (declare-function math-compare-bignum "calc-ext" (a b)) |
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
36 |
577a47c95cf8
(math-zerop, math-negp, math-looks-negp)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
78215
diff
changeset
|
37 |
40785 | 38 (defmacro calc-wrapper (&rest body) |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
39 `(calc-do (function (lambda () |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
40 ,@body)))) |
40785 | 41 |
42 (defmacro calc-slow-wrapper (&rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
43 `(calc-do |
41341
6ab668229754
(calc-slow-wrapper): Move (point) call outside of (function ...)
Colin Walters <walters@gnu.org>
parents:
41266
diff
changeset
|
44 (function (lambda () ,@body)) (point))) |
40785 | 45 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
46 (defmacro math-showing-full-precision (form) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
47 `(let ((calc-float-format calc-full-float-format)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
48 ,form)) |
40785 | 49 |
50 (defmacro math-with-extra-prec (delta &rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
51 `(math-normalize |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
52 (let ((calc-internal-prec (+ calc-internal-prec ,delta))) |
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 math-working (msg arg) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
56 `(if (eq calc-display-working-message 'lots) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
57 (math-do-working ,msg ,arg))) |
40785 | 58 |
43402
b7527fba7b15
(calc-with-default-simplification): Use &rest for body.
Colin Walters <walters@gnu.org>
parents:
41385
diff
changeset
|
59 (defmacro calc-with-default-simplification (&rest body) |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
60 `(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
|
61 calc-simplify-mode))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
62 ,@body)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
63 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
64 (defmacro calc-with-trail-buffer (&rest body) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
65 `(let ((save-buf (current-buffer)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
66 (calc-command-flags nil)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
67 (with-current-buffer (calc-trail-display t) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
68 (progn |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
69 (goto-char calc-trail-pointer) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
70 ,@body)))) |
40785 | 71 |
72 ;;; Faster in-line version zerop, normalized values only. | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
73 (defsubst Math-zerop (a) ; [P N] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
74 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
75 (and (not (memq (car a) '(bigpos bigneg))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
76 (if (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
77 (eq (nth 1 a) 0) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
78 (math-zerop a))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
79 (eq a 0))) |
40785 | 80 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
81 (defsubst Math-integer-negp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
82 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
83 (eq (car a) 'bigneg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
84 (< a 0))) |
40785 | 85 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
86 (defsubst Math-integer-posp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
87 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
88 (eq (car a) 'bigpos) |
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-negp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
92 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
93 (or (eq (car a) 'bigneg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
94 (and (not (eq (car a) 'bigpos)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
95 (if (memq (car a) '(frac float)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
96 (Math-integer-negp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
97 (math-negp a)))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
98 (< a 0))) |
40785 | 99 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
100 (defsubst Math-looks-negp (a) ; [P x] [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
101 (or (Math-negp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
102 (and (consp a) (or (eq (car a) 'neg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
103 (and (memq (car a) '(* /)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
104 (or (math-looks-negp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
105 (math-looks-negp (nth 2 a)))))))) |
40785 | 106 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
107 (defsubst Math-posp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
108 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
109 (or (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
110 (and (not (eq (car a) 'bigneg)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
111 (if (memq (car a) '(frac float)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
112 (Math-integer-posp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
113 (math-posp a)))) |
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-integerp (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)))) |
40785 | 119 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
120 (defsubst Math-natnump (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
121 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
122 (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
123 (>= a 0))) |
40785 | 124 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
125 (defsubst Math-ratp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
126 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
127 (memq (car a) '(bigpos bigneg frac)))) |
40785 | 128 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
129 (defsubst Math-realp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
130 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
131 (memq (car a) '(bigpos bigneg frac float)))) |
40785 | 132 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
133 (defsubst Math-anglep (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
134 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
135 (memq (car a) '(bigpos bigneg frac float hms)))) |
40785 | 136 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
137 (defsubst Math-numberp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
138 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
139 (memq (car a) '(bigpos bigneg frac float cplx polar)))) |
40785 | 140 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
141 (defsubst Math-scalarp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
142 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
143 (memq (car a) '(bigpos bigneg frac float cplx polar hms)))) |
40785 | 144 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
145 (defsubst Math-vectorp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
146 (and (consp a) (eq (car a) 'vec))) |
40785 | 147 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
148 (defsubst Math-messy-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
149 (and (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
150 (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
151 (>= (nth 2 a) 0))) |
40785 | 152 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
153 (defsubst Math-objectp (a) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
154 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
155 (memq (car a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
156 '(bigpos bigneg frac float cplx polar hms date sdev intv mod)))) |
40785 | 157 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
158 (defsubst Math-objvecp (a) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
159 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
160 (memq (car a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
161 '(bigpos bigneg frac float cplx polar hms date |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
162 sdev intv mod vec)))) |
40785 | 163 |
164 ;;; 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
|
165 (defsubst Math-integer-neg (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
166 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
167 (if (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
168 (cons 'bigneg (cdr a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
169 (cons 'bigpos (cdr a))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
170 (- a))) |
40785 | 171 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
172 (defsubst Math-equal (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
173 (= (math-compare a b) 0)) |
40785 | 174 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
175 (defsubst Math-lessp (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
176 (= (math-compare a b) -1)) |
40785 | 177 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
178 (defsubst Math-primp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
179 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
180 (memq (car a) '(bigpos bigneg frac float cplx polar |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
181 hms date mod var)))) |
40785 | 182 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
183 (defsubst Math-num-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
184 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
185 (memq (car a) '(bigpos bigneg)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
186 (and (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
187 (>= (nth 2 a) 0)))) |
40785 | 188 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
189 (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
|
190 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
191 a |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
192 (math-bignum a))) |
40785 | 193 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
194 (defsubst Math-equal-int (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
195 (or (eq a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
196 (and (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
197 (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
198 (eq (nth 1 a) b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
199 (= (nth 2 a) 0)))) |
40785 | 200 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
201 (defsubst Math-natnum-lessp (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
202 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
203 (and (consp b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
204 (= (math-compare-bignum (cdr a) (cdr b)) -1)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
205 (or (consp b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
206 (< a b)))) |
40785 | 207 |
58612
d48ee50961f3
Move provide to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
208 (provide 'calc-macs) |
d48ee50961f3
Move provide to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
209 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
210 ;; 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
|
211 ;;; calc-macs.el ends here |