aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters2001-11-14 09:03:32 +0000
committerColin Walters2001-11-14 09:03:32 +0000
commitcce7e5a603b28b4059de9f03abb2df722344c875 (patch)
treea0904625469a8ae6012a6c9afa338a16ce93b4be
parent7d70a3ba4e9fb49e592b3399a116363ccfa0e9e6 (diff)
downloademacs-cce7e5a603b28b4059de9f03abb2df722344c875.tar.gz
emacs-cce7e5a603b28b4059de9f03abb2df722344c875.zip
(calcFunc-evalv): Use `defalias' instead of `fset' and
`symbol-function'. Style cleanup; don't put closing parens on their own line, add "foo.el ends here" to each file, and update copyright date.
-rw-r--r--lisp/calc/calc-ext.el405
1 files changed, 127 insertions, 278 deletions
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el
index d827c98543e..031ffae9b85 100644
--- a/lisp/calc/calc-ext.el
+++ b/lisp/calc/calc-ext.el
@@ -1,5 +1,5 @@
1;; Calculator for GNU Emacs, part II 1;; Calculator for GNU Emacs, part II
2;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. 2;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
3;; Written by Dave Gillespie, daveg@synaptics.com. 3;; Written by Dave Gillespie, daveg@synaptics.com.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
@@ -30,8 +30,7 @@
30;;;###autoload 30;;;###autoload
31(defun calc-extensions () 31(defun calc-extensions ()
32 "This function is part of the autoload linkage for parts of Calc." 32 "This function is part of the autoload linkage for parts of Calc."
33 t 33 t)
34)
35 34
36;;; Auto-load calc.el part, in case this part was loaded first. 35;;; Auto-load calc.el part, in case this part was loaded first.
37(if (fboundp 'calc-dispatch) 36(if (fboundp 'calc-dispatch)
@@ -1133,7 +1132,6 @@ calc-copy-to-buffer calc-edit calc-edit-cancel calc-edit-mode
1133calc-kill calc-kill-region calc-yank) 1132calc-kill calc-kill-region calc-yank)
1134 1133
1135)) 1134))
1136
1137) 1135)
1138 1136
1139(defun calc-init-prefixes () 1137(defun calc-init-prefixes ()
@@ -1162,8 +1160,7 @@ calc-kill calc-kill-region calc-yank)
1162 (define-key calc-mode-map "M" 'calc-more-recursion-depth) 1160 (define-key calc-mode-map "M" 'calc-more-recursion-depth)
1163 (define-key calc-mode-map "S" 'calc-sin) 1161 (define-key calc-mode-map "S" 'calc-sin)
1164 (define-key calc-mode-map "T" 'calc-tan) 1162 (define-key calc-mode-map "T" 'calc-tan)
1165 (define-key calc-mode-map "U" 'calc-undo)) 1163 (define-key calc-mode-map "U" 'calc-undo)))
1166)
1167 1164
1168(calc-init-extensions) 1165(calc-init-extensions)
1169 1166
@@ -1173,16 +1170,14 @@ calc-kill calc-kill-region calc-yank)
1173;;;; Miscellaneous. 1170;;;; Miscellaneous.
1174 1171
1175(defun calc-clear-command-flag (f) 1172(defun calc-clear-command-flag (f)
1176 (setq calc-command-flags (delq f calc-command-flags)) 1173 (setq calc-command-flags (delq f calc-command-flags)))
1177)
1178 1174
1179 1175
1180(defun calc-record-message (tag &rest args) 1176(defun calc-record-message (tag &rest args)
1181 (let ((msg (apply 'format args))) 1177 (let ((msg (apply 'format args)))
1182 (message "%s" msg) 1178 (message "%s" msg)
1183 (calc-record msg tag)) 1179 (calc-record msg tag))
1184 (calc-clear-command-flag 'clear-message) 1180 (calc-clear-command-flag 'clear-message))
1185)
1186 1181
1187 1182
1188(defun calc-normalize-fancy (val) 1183(defun calc-normalize-fancy (val)
@@ -1201,8 +1196,7 @@ calc-kill calc-kill-region calc-yank)
1201 ((eq simp 'units) 1196 ((eq simp 'units)
1202 (math-simplify-units val)) 1197 (math-simplify-units val))
1203 (t ; nil, none, num 1198 (t ; nil, none, num
1204 (math-normalize val)))) 1199 (math-normalize val)))))
1205)
1206 1200
1207 1201
1208 1202
@@ -1224,8 +1218,7 @@ calc-kill calc-kill-region calc-yank)
1224 (define-key calc-help-map "\C-n" 'calc-view-news) 1218 (define-key calc-help-map "\C-n" 'calc-view-news)
1225 (define-key calc-help-map "\C-w" 'calc-describe-no-warranty) 1219 (define-key calc-help-map "\C-w" 'calc-describe-no-warranty)
1226 (define-key calc-help-map "?" 'calc-help-for-help) 1220 (define-key calc-help-map "?" 'calc-help-for-help)
1227 (define-key calc-help-map "\C-h" 'calc-help-for-help) 1221 (define-key calc-help-map "\C-h" 'calc-help-for-help))
1228)
1229 1222
1230 1223
1231(defun calc-do-prefix-help (msgs group key) 1224(defun calc-do-prefix-help (msgs group key)
@@ -1255,8 +1248,7 @@ calc-kill calc-kill-region calc-yank)
1255 (message "%s: %s: %c-" group (car msgs) key) 1248 (message "%s: %s: %c-" group (car msgs) key)
1256 (message "%s: (none) %c-" group (car msgs) key)) 1249 (message "%s: (none) %c-" group (car msgs) key))
1257 (message "%s: %s" group (car msgs)))) 1250 (message "%s: %s" group (car msgs))))
1258 (and key (calc-unread-command key))) 1251 (and key (calc-unread-command key))))
1259)
1260(defvar calc-prefix-help-phase 0) 1252(defvar calc-prefix-help-phase 0)
1261 1253
1262 1254
@@ -1299,19 +1291,16 @@ calc-kill calc-kill-region calc-yank)
1299 (select-window win) 1291 (select-window win)
1300 (enlarge-window (- calc-window-height height)) 1292 (enlarge-window (- calc-window-height height))
1301 (select-window swin))))))) 1293 (select-window swin)))))))
1302 (message "(Calculator reset)") 1294 (message "(Calculator reset)"))
1303)
1304 1295
1305 1296
1306(defun calc-scroll-left (n) 1297(defun calc-scroll-left (n)
1307 (interactive "P") 1298 (interactive "P")
1308 (scroll-left (or n (/ (window-width) 2))) 1299 (scroll-left (or n (/ (window-width) 2))))
1309)
1310 1300
1311(defun calc-scroll-right (n) 1301(defun calc-scroll-right (n)
1312 (interactive "P") 1302 (interactive "P")
1313 (scroll-right (or n (/ (window-width) 2))) 1303 (scroll-right (or n (/ (window-width) 2))))
1314)
1315 1304
1316(defun calc-scroll-up (n) 1305(defun calc-scroll-up (n)
1317 (interactive "P") 1306 (interactive "P")
@@ -1326,14 +1315,12 @@ calc-kill calc-kill-region calc-yank)
1326 (save-excursion 1315 (save-excursion
1327 (forward-line (- (1- (window-height)))) 1316 (forward-line (- (1- (window-height))))
1328 (point))) 1317 (point)))
1329 (forward-line -1))) 1318 (forward-line -1))))
1330)
1331 1319
1332(defun calc-scroll-down (n) 1320(defun calc-scroll-down (n)
1333 (interactive "P") 1321 (interactive "P")
1334 (or (pos-visible-in-window-p 1) 1322 (or (pos-visible-in-window-p 1)
1335 (scroll-down (or n (/ (window-height) 2)))) 1323 (scroll-down (or n (/ (window-height) 2)))))
1336)
1337 1324
1338 1325
1339(defun calc-precision (n) 1326(defun calc-precision (n)
@@ -1346,14 +1333,12 @@ calc-kill calc-kill-region calc-yank)
1346 (< (nth 1 calc-float-format) 1333 (< (nth 1 calc-float-format)
1347 (if (= calc-number-radix 10) 0 1)))) 1334 (if (= calc-number-radix 10) 0 1))))
1348 (calc-record calc-internal-prec "prec")) 1335 (calc-record calc-internal-prec "prec"))
1349 (message "Floating-point precision is %d digits." calc-internal-prec)) 1336 (message "Floating-point precision is %d digits." calc-internal-prec)))
1350)
1351 1337
1352 1338
1353(defun calc-inverse (&optional n) 1339(defun calc-inverse (&optional n)
1354 (interactive "P") 1340 (interactive "P")
1355 (calc-fancy-prefix 'calc-inverse-flag "Inverse..." n) 1341 (calc-fancy-prefix 'calc-inverse-flag "Inverse..." n))
1356)
1357 1342
1358(defconst calc-fancy-prefix-map 1343(defconst calc-fancy-prefix-map
1359 (let ((map (make-sparse-keymap))) 1344 (let ((map (make-sparse-keymap)))
@@ -1415,34 +1400,28 @@ calc-kill calc-kill-region calc-yank)
1415 (calc-select-buffer) 1400 (calc-select-buffer)
1416 (setq calc-inverse-flag (not (calc-is-inverse)) 1401 (setq calc-inverse-flag (not (calc-is-inverse))
1417 calc-hyperbolic-flag (calc-is-hyperbolic) 1402 calc-hyperbolic-flag (calc-is-hyperbolic)
1418 current-prefix-arg nil)) 1403 current-prefix-arg nil)))
1419)
1420 1404
1421(defun calc-is-inverse () 1405(defun calc-is-inverse ()
1422 calc-inverse-flag 1406 calc-inverse-flag)
1423)
1424 1407
1425(defun calc-hyperbolic (&optional n) 1408(defun calc-hyperbolic (&optional n)
1426 (interactive "P") 1409 (interactive "P")
1427 (calc-fancy-prefix 'calc-hyperbolic-flag "Hyperbolic..." n) 1410 (calc-fancy-prefix 'calc-hyperbolic-flag "Hyperbolic..." n))
1428)
1429 1411
1430(defun calc-hyperbolic-func () 1412(defun calc-hyperbolic-func ()
1431 (save-excursion 1413 (save-excursion
1432 (calc-select-buffer) 1414 (calc-select-buffer)
1433 (setq calc-inverse-flag (calc-is-inverse) 1415 (setq calc-inverse-flag (calc-is-inverse)
1434 calc-hyperbolic-flag (not (calc-is-hyperbolic)) 1416 calc-hyperbolic-flag (not (calc-is-hyperbolic))
1435 current-prefix-arg nil)) 1417 current-prefix-arg nil)))
1436)
1437 1418
1438(defun calc-is-hyperbolic () 1419(defun calc-is-hyperbolic ()
1439 calc-hyperbolic-flag 1420 calc-hyperbolic-flag)
1440)
1441 1421
1442(defun calc-keep-args (&optional n) 1422(defun calc-keep-args (&optional n)
1443 (interactive "P") 1423 (interactive "P")
1444 (calc-fancy-prefix 'calc-keep-args-flag "Keep args..." n) 1424 (calc-fancy-prefix 'calc-keep-args-flag "Keep args..." n))
1445)
1446 1425
1447 1426
1448(defun calc-change-mode (var value &optional refresh option) 1427(defun calc-change-mode (var value &optional refresh option)
@@ -1496,8 +1475,7 @@ calc-kill calc-kill-region calc-yank)
1496 (not (equal var '(calc-mode-save-mode))) 1475 (not (equal var '(calc-mode-save-mode)))
1497 (calc-save-modes t)))) 1476 (calc-save-modes t))))
1498 (if calc-embedded-info (calc-embedded-modes-change var)) 1477 (if calc-embedded-info (calc-embedded-modes-change var))
1499 (symbol-value (car var)))) 1478 (symbol-value (car var)))))
1500)
1501 1479
1502(defun calc-refresh-top (n) 1480(defun calc-refresh-top (n)
1503 (interactive "p") 1481 (interactive "p")
@@ -1517,8 +1495,7 @@ calc-kill calc-kill-region calc-yank)
1517 (calc-push-list (mapcar 'car entries) 1495 (calc-push-list (mapcar 'car entries)
1518 1 1496 1
1519 (mapcar (function (lambda (x) (nth 2 x))) 1497 (mapcar (function (lambda (x) (nth 2 x)))
1520 entries)))))) 1498 entries)))))))
1521)
1522 1499
1523(defun calc-refresh-evaltos (&optional which-var) 1500(defun calc-refresh-evaltos (&optional which-var)
1524 (and calc-any-evaltos calc-auto-recompute (not calc-no-refresh-evaltos) 1501 (and calc-any-evaltos calc-auto-recompute (not calc-no-refresh-evaltos)
@@ -1541,23 +1518,19 @@ calc-kill calc-kill-region calc-yank)
1541 (calc-pop-stack 1 (1+ num) t))))) 1518 (calc-pop-stack 1 (1+ num) t)))))
1542 (setq num (1- num))))) 1519 (setq num (1- num)))))
1543 (and calc-embedded-active which-var 1520 (and calc-embedded-active which-var
1544 (calc-embedded-var-change which-var)) 1521 (calc-embedded-var-change which-var)))
1545)
1546(setq calc-refreshing-evaltos nil) 1522(setq calc-refreshing-evaltos nil)
1547(setq calc-no-refresh-evaltos nil) 1523(setq calc-no-refresh-evaltos nil)
1548 1524
1549 1525
1550(defun calc-push (&rest vals) 1526(defun calc-push (&rest vals)
1551 (calc-push-list vals) 1527 (calc-push-list vals))
1552)
1553 1528
1554(defun calc-pop-push (n &rest vals) 1529(defun calc-pop-push (n &rest vals)
1555 (calc-pop-push-list n vals) 1530 (calc-pop-push-list n vals))
1556)
1557 1531
1558(defun calc-pop-push-record (n prefix &rest vals) 1532(defun calc-pop-push-record (n prefix &rest vals)
1559 (calc-pop-push-record-list n prefix vals) 1533 (calc-pop-push-record-list n prefix vals))
1560)
1561 1534
1562 1535
1563(defun calc-evaluate (n) 1536(defun calc-evaluate (n)
@@ -1572,8 +1545,7 @@ calc-kill calc-kill-region calc-yank)
1572 (- n)) 1545 (- n))
1573 (calc-pop-push-record-list n "eval" (mapcar 'math-evaluate-expr 1546 (calc-pop-push-record-list n "eval" (mapcar 'math-evaluate-expr
1574 (calc-top-list n))))) 1547 (calc-top-list n)))))
1575 (calc-handle-whys)) 1548 (calc-handle-whys)))
1576)
1577 1549
1578 1550
1579(defun calc-eval-num (n) 1551(defun calc-eval-num (n)
@@ -1587,8 +1559,7 @@ calc-kill calc-kill-region calc-yank)
1587 (calc-symbolic-mode nil)) 1559 (calc-symbolic-mode nil))
1588 (calc-with-default-simplification 1560 (calc-with-default-simplification
1589 (calc-pop-push-record 1 "num" (math-evaluate-expr (calc-top 1))))) 1561 (calc-pop-push-record 1 "num" (math-evaluate-expr (calc-top 1)))))
1590 (calc-handle-whys)) 1562 (calc-handle-whys)))
1591)
1592 1563
1593 1564
1594(defun calc-execute-extended-command (n) 1565(defun calc-execute-extended-command (n)
@@ -1596,8 +1567,7 @@ calc-kill calc-kill-region calc-yank)
1596 (let* ((prompt (concat (calc-num-prefix-name n) "M-x ")) 1567 (let* ((prompt (concat (calc-num-prefix-name n) "M-x "))
1597 (cmd (intern (completing-read prompt obarray 'commandp t "calc-")))) 1568 (cmd (intern (completing-read prompt obarray 'commandp t "calc-"))))
1598 (setq prefix-arg n) 1569 (setq prefix-arg n)
1599 (command-execute cmd)) 1570 (command-execute cmd)))
1600)
1601 1571
1602 1572
1603(defun calc-realign (&optional num) 1573(defun calc-realign (&optional num)
@@ -1617,8 +1587,7 @@ calc-kill calc-kill-region calc-yank)
1617 (forward-line 1))) 1587 (forward-line 1)))
1618 (calc-wrapper 1588 (calc-wrapper
1619 (if (get-buffer-window (current-buffer)) 1589 (if (get-buffer-window (current-buffer))
1620 (set-window-hscroll (get-buffer-window (current-buffer)) 0))))) 1590 (set-window-hscroll (get-buffer-window (current-buffer)) 0))))))
1621)
1622 1591
1623 1592
1624 1593
@@ -1638,8 +1607,7 @@ calc-kill calc-kill-region calc-yank)
1638 (if (eq (car-safe val) 'error) 1607 (if (eq (car-safe val) 'error)
1639 (error "Bad format in variable contents: %s" (nth 2 val)) 1608 (error "Bad format in variable contents: %s" (nth 2 val))
1640 (set v val))) 1609 (set v val)))
1641 (symbol-value v)))) 1610 (symbol-value v)))))
1642)
1643 1611
1644 1612
1645 1613
@@ -1683,8 +1651,7 @@ calc-kill calc-kill-region calc-yank)
1683 (calc-slow-wrapper 1651 (calc-slow-wrapper
1684 (calc-unary-op "flt" 1652 (calc-unary-op "flt"
1685 (if (calc-is-hyperbolic) 'calcFunc-float 'calcFunc-pfloat) 1653 (if (calc-is-hyperbolic) 'calcFunc-float 'calcFunc-pfloat)
1686 arg)) 1654 arg)))
1687)
1688 1655
1689 1656
1690(defvar calc-gnuplot-process nil) 1657(defvar calc-gnuplot-process nil)
@@ -1696,8 +1663,7 @@ calc-kill calc-kill-region calc-yank)
1696 (buffer-name calc-gnuplot-buffer) 1663 (buffer-name calc-gnuplot-buffer)
1697 calc-gnuplot-input 1664 calc-gnuplot-input
1698 (buffer-name calc-gnuplot-input) 1665 (buffer-name calc-gnuplot-input)
1699 (memq (process-status calc-gnuplot-process) '(run stop))) 1666 (memq (process-status calc-gnuplot-process) '(run stop))))
1700)
1701 1667
1702 1668
1703 1669
@@ -1747,8 +1713,7 @@ calc-kill calc-kill-region calc-yank)
1747 (calc-Need-calc-vec) 1713 (calc-Need-calc-vec)
1748 (calc-Need-calc-yank) 1714 (calc-Need-calc-yank)
1749 1715
1750 (message "All parts of Calc are now loaded.") 1716 (message "All parts of Calc are now loaded."))
1751)
1752 1717
1753 1718
1754;;; Vector commands. 1719;;; Vector commands.
@@ -1764,14 +1729,12 @@ calc-kill calc-kill-region calc-yank)
1764 (calc-top 1) (calc-top 2)))) 1729 (calc-top 1) (calc-top 2))))
1765 (if (calc-is-hyperbolic) 1730 (if (calc-is-hyperbolic)
1766 (calc-binary-op "apnd" 'calcFunc-append arg '(vec)) 1731 (calc-binary-op "apnd" 'calcFunc-append arg '(vec))
1767 (calc-binary-op "|" 'calcFunc-vconcat arg '(vec) nil '|)))) 1732 (calc-binary-op "|" 'calcFunc-vconcat arg '(vec) nil '|)))))
1768)
1769 1733
1770(defun calc-append (arg) 1734(defun calc-append (arg)
1771 (interactive "P") 1735 (interactive "P")
1772 (calc-hyperbolic-func) 1736 (calc-hyperbolic-func)
1773 (calc-concat arg) 1737 (calc-concat arg))
1774)
1775 1738
1776 1739
1777(defconst calc-arg-values '( ( var ArgA var-ArgA ) ( var ArgB var-ArgB ) 1740(defconst calc-arg-values '( ( var ArgA var-ArgA ) ( var ArgB var-ArgB )
@@ -1782,8 +1745,7 @@ calc-kill calc-kill-region calc-yank)
1782)) 1745))
1783 1746
1784(defun calc-invent-args (n) 1747(defun calc-invent-args (n)
1785 (nreverse (nthcdr (- (length calc-arg-values) n) (reverse calc-arg-values))) 1748 (nreverse (nthcdr (- (length calc-arg-values) n) (reverse calc-arg-values))))
1786)
1787 1749
1788 1750
1789 1751
@@ -1796,8 +1758,7 @@ calc-kill calc-kill-region calc-yank)
1796 (let ((res (cdr (lookup-key calc-mode-map "z")))) 1758 (let ((res (cdr (lookup-key calc-mode-map "z"))))
1797 (if (eq (car (car res)) 27) 1759 (if (eq (car (car res)) 27)
1798 (cdr res) 1760 (cdr res)
1799 res)) 1761 res)))
1800)
1801 1762
1802(defun calc-z-prefix-help () 1763(defun calc-z-prefix-help ()
1803 (interactive) 1764 (interactive)
@@ -1818,16 +1779,14 @@ calc-kill calc-kill-region calc-yank)
1818 (calc-user-function-list kmap 6)) 1779 (calc-user-function-list kmap 6))
1819 (if (/= flags 0) 1780 (if (/= flags 0)
1820 (setq msgs (cons buf msgs))) 1781 (setq msgs (cons buf msgs)))
1821 (calc-do-prefix-help (nreverse msgs) "user" ?z)) 1782 (calc-do-prefix-help (nreverse msgs) "user" ?z)))
1822)
1823 1783
1824(defun calc-user-function-classify (key) 1784(defun calc-user-function-classify (key)
1825 (cond ((/= key (downcase key)) ; upper-case 1785 (cond ((/= key (downcase key)) ; upper-case
1826 (if (assq (downcase key) (calc-user-key-map)) 9 1)) 1786 (if (assq (downcase key) (calc-user-key-map)) 9 1))
1827 ((/= key (upcase key)) 2) ; lower-case 1787 ((/= key (upcase key)) 2) ; lower-case
1828 ((= key ??) 0) 1788 ((= key ??) 0)
1829 (t 4)) ; other 1789 (t 4))) ; other
1830)
1831 1790
1832(defun calc-user-function-list (map flags) 1791(defun calc-user-function-list (map flags)
1833 (and map 1792 (and map
@@ -1862,8 +1821,7 @@ calc-kill calc-kill-region calc-yank)
1862 buf (concat (if (= flags 1) "SHIFT + " "") 1821 buf (concat (if (= flags 1) "SHIFT + " "")
1863 desc)) 1822 desc))
1864 (setq buf (concat buf ", " desc)))))) 1823 (setq buf (concat buf ", " desc))))))
1865 (calc-user-function-list (cdr map) flags))) 1824 (calc-user-function-list (cdr map) flags))))
1866)
1867 1825
1868 1826
1869 1827
@@ -1876,8 +1834,7 @@ calc-kill calc-kill-region calc-yank)
1876 "kbd-macros: < > (repeat), ( ) (for), { } (loop)" 1834 "kbd-macros: < > (repeat), ( ) (for), { } (loop)"
1877 "kbd-macros: / (break)" 1835 "kbd-macros: / (break)"
1878 "kbd-macros: ` (save), ' (restore)") 1836 "kbd-macros: ` (save), ' (restore)")
1879 "user" ?Z) 1837 "user" ?Z))
1880)
1881 1838
1882 1839
1883;;;; Caches. 1840;;;; Caches.
@@ -1920,8 +1877,7 @@ calc-kill calc-kill-region calc-yank)
1920 '(+ calc-internal-prec 2))) 1877 '(+ calc-internal-prec 2)))
1921 cache-val)) 1878 cache-val))
1922 last-prec 'calc-internal-prec)) 1879 last-prec 'calc-internal-prec))
1923 last-val))) 1880 last-val))))
1924)
1925(put 'math-defcache 'lisp-indent-hook 2) 1881(put 'math-defcache 'lisp-indent-hook 2)
1926 1882
1927;;; Betcha didn't know that pi = 16 atan(1/5) - 4 atan(1/239). [F] [Public] 1883;;; Betcha didn't know that pi = 16 atan(1/5) - 4 atan(1/239). [F] [Public]
@@ -1976,16 +1932,13 @@ calc-kill calc-kill-region calc-yank)
1976 (if symb 1932 (if symb
1977 '(var pi var-pi) 1933 '(var pi var-pi)
1978 (math-pi)) 1934 (math-pi))
1979 180) 1935 180))
1980)
1981 1936
1982(defun math-full-circle (symb) 1937(defun math-full-circle (symb)
1983 (math-mul 2 (math-half-circle symb)) 1938 (math-mul 2 (math-half-circle symb)))
1984)
1985 1939
1986(defun math-quarter-circle (symb) 1940(defun math-quarter-circle (symb)
1987 (math-div (math-half-circle symb) 2) 1941 (math-div (math-half-circle symb) 2))
1988)
1989 1942
1990 1943
1991 1944
@@ -1997,82 +1950,69 @@ calc-kill calc-kill-region calc-yank)
1997 (if (consp a) 1950 (if (consp a)
1998 (and (memq (car a) '(bigpos bigneg)) 1951 (and (memq (car a) '(bigpos bigneg))
1999 (= (% (nth 1 a) 2) 1)) 1952 (= (% (nth 1 a) 2) 1))
2000 (/= (% a 2) 0)) 1953 (/= (% a 2) 0)))
2001)
2002 1954
2003;;; True if A is a small or big integer. [P x] [Public] 1955;;; True if A is a small or big integer. [P x] [Public]
2004(defun math-integerp (a) 1956(defun math-integerp (a)
2005 (or (integerp a) 1957 (or (integerp a)
2006 (memq (car-safe a) '(bigpos bigneg))) 1958 (memq (car-safe a) '(bigpos bigneg))))
2007)
2008 1959
2009;;; True if A is (numerically) a non-negative integer. [P N] [Public] 1960;;; True if A is (numerically) a non-negative integer. [P N] [Public]
2010(defun math-natnump (a) 1961(defun math-natnump (a)
2011 (or (natnump a) 1962 (or (natnump a)
2012 (eq (car-safe a) 'bigpos)) 1963 (eq (car-safe a) 'bigpos)))
2013)
2014 1964
2015;;; True if A is a rational (or integer). [P x] [Public] 1965;;; True if A is a rational (or integer). [P x] [Public]
2016(defun math-ratp (a) 1966(defun math-ratp (a)
2017 (or (integerp a) 1967 (or (integerp a)
2018 (memq (car-safe a) '(bigpos bigneg frac))) 1968 (memq (car-safe a) '(bigpos bigneg frac))))
2019)
2020 1969
2021;;; True if A is a real (or rational). [P x] [Public] 1970;;; True if A is a real (or rational). [P x] [Public]
2022(defun math-realp (a) 1971(defun math-realp (a)
2023 (or (integerp a) 1972 (or (integerp a)
2024 (memq (car-safe a) '(bigpos bigneg frac float))) 1973 (memq (car-safe a) '(bigpos bigneg frac float))))
2025)
2026 1974
2027;;; True if A is a real or HMS form. [P x] [Public] 1975;;; True if A is a real or HMS form. [P x] [Public]
2028(defun math-anglep (a) 1976(defun math-anglep (a)
2029 (or (integerp a) 1977 (or (integerp a)
2030 (memq (car-safe a) '(bigpos bigneg frac float hms))) 1978 (memq (car-safe a) '(bigpos bigneg frac float hms))))
2031)
2032 1979
2033;;; True if A is a number of any kind. [P x] [Public] 1980;;; True if A is a number of any kind. [P x] [Public]
2034(defun math-numberp (a) 1981(defun math-numberp (a)
2035 (or (integerp a) 1982 (or (integerp a)
2036 (memq (car-safe a) '(bigpos bigneg frac float cplx polar))) 1983 (memq (car-safe a) '(bigpos bigneg frac float cplx polar))))
2037)
2038 1984
2039;;; True if A is a complex number or angle. [P x] [Public] 1985;;; True if A is a complex number or angle. [P x] [Public]
2040(defun math-scalarp (a) 1986(defun math-scalarp (a)
2041 (or (integerp a) 1987 (or (integerp a)
2042 (memq (car-safe a) '(bigpos bigneg frac float cplx polar hms))) 1988 (memq (car-safe a) '(bigpos bigneg frac float cplx polar hms))))
2043)
2044 1989
2045;;; True if A is a vector. [P x] [Public] 1990;;; True if A is a vector. [P x] [Public]
2046(defun math-vectorp (a) 1991(defun math-vectorp (a)
2047 (eq (car-safe a) 'vec) 1992 (eq (car-safe a) 'vec))
2048)
2049 1993
2050;;; True if A is any vector or scalar data object. [P x] 1994;;; True if A is any vector or scalar data object. [P x]
2051(defun math-objvecp (a) ; [Public] 1995(defun math-objvecp (a) ; [Public]
2052 (or (integerp a) 1996 (or (integerp a)
2053 (memq (car-safe a) '(bigpos bigneg frac float cplx polar 1997 (memq (car-safe a) '(bigpos bigneg frac float cplx polar
2054 hms date sdev intv mod vec incomplete))) 1998 hms date sdev intv mod vec incomplete))))
2055)
2056 1999
2057;;; True if A is an object not composed of sub-formulas . [P x] [Public] 2000;;; True if A is an object not composed of sub-formulas . [P x] [Public]
2058(defun math-primp (a) 2001(defun math-primp (a)
2059 (or (integerp a) 2002 (or (integerp a)
2060 (memq (car-safe a) '(bigpos bigneg frac float cplx polar 2003 (memq (car-safe a) '(bigpos bigneg frac float cplx polar
2061 hms date mod var))) 2004 hms date mod var))))
2062)
2063 2005
2064;;; True if A is numerically (but not literally) an integer. [P x] [Public] 2006;;; True if A is numerically (but not literally) an integer. [P x] [Public]
2065(defun math-messy-integerp (a) 2007(defun math-messy-integerp (a)
2066 (cond 2008 (cond
2067 ((eq (car-safe a) 'float) (>= (nth 2 a) 0)) 2009 ((eq (car-safe a) 'float) (>= (nth 2 a) 0))
2068 ((eq (car-safe a) 'frac) (Math-integerp (math-normalize a)))) 2010 ((eq (car-safe a) 'frac) (Math-integerp (math-normalize a)))))
2069)
2070 2011
2071;;; True if A is numerically an integer. [P x] [Public] 2012;;; True if A is numerically an integer. [P x] [Public]
2072(defun math-num-integerp (a) 2013(defun math-num-integerp (a)
2073 (or (Math-integerp a) 2014 (or (Math-integerp a)
2074 (Math-messy-integerp a)) 2015 (Math-messy-integerp a)))
2075)
2076 2016
2077;;; True if A is (numerically) a non-negative integer. [P N] [Public] 2017;;; True if A is (numerically) a non-negative integer. [P N] [Public]
2078(defun math-num-natnump (a) 2018(defun math-num-natnump (a)
@@ -2080,8 +2020,7 @@ calc-kill calc-kill-region calc-yank)
2080 (eq (car-safe a) 'bigpos) 2020 (eq (car-safe a) 'bigpos)
2081 (and (eq (car-safe a) 'float) 2021 (and (eq (car-safe a) 'float)
2082 (Math-natnump (nth 1 a)) 2022 (Math-natnump (nth 1 a))
2083 (>= (nth 2 a) 0))) 2023 (>= (nth 2 a) 0))))
2084)
2085 2024
2086;;; True if A is an integer or will evaluate to an integer. [P x] [Public] 2025;;; True if A is an integer or will evaluate to an integer. [P x] [Public]
2087(defun math-provably-integerp (a) 2026(defun math-provably-integerp (a)
@@ -2092,30 +2031,25 @@ calc-kill calc-kill-region calc-yank)
2092 calcFunc-roundu 2031 calcFunc-roundu
2093 calcFunc-floor 2032 calcFunc-floor
2094 calcFunc-ceil)) 2033 calcFunc-ceil))
2095 (= (length a) 2))) 2034 (= (length a) 2))))
2096)
2097 2035
2098;;; True if A is a real or will evaluate to a real. [P x] [Public] 2036;;; True if A is a real or will evaluate to a real. [P x] [Public]
2099(defun math-provably-realp (a) 2037(defun math-provably-realp (a)
2100 (or (Math-realp a) 2038 (or (Math-realp a)
2101 (math-provably-integer a) 2039 (math-provably-integer a)
2102 (memq (car-safe a) '(abs arg))) 2040 (memq (car-safe a) '(abs arg))))
2103)
2104 2041
2105;;; True if A is a non-real, complex number. [P x] [Public] 2042;;; True if A is a non-real, complex number. [P x] [Public]
2106(defun math-complexp (a) 2043(defun math-complexp (a)
2107 (memq (car-safe a) '(cplx polar)) 2044 (memq (car-safe a) '(cplx polar)))
2108)
2109 2045
2110;;; True if A is a non-real, rectangular complex number. [P x] [Public] 2046;;; True if A is a non-real, rectangular complex number. [P x] [Public]
2111(defun math-rect-complexp (a) 2047(defun math-rect-complexp (a)
2112 (eq (car-safe a) 'cplx) 2048 (eq (car-safe a) 'cplx))
2113)
2114 2049
2115;;; True if A is a non-real, polar complex number. [P x] [Public] 2050;;; True if A is a non-real, polar complex number. [P x] [Public]
2116(defun math-polar-complexp (a) 2051(defun math-polar-complexp (a)
2117 (eq (car-safe a) 'polar) 2052 (eq (car-safe a) 'polar))
2118)
2119 2053
2120;;; True if A is a matrix. [P x] [Public] 2054;;; True if A is a matrix. [P x] [Public]
2121(defun math-matrixp (a) 2055(defun math-matrixp (a)
@@ -2127,29 +2061,25 @@ calc-kill calc-kill-region calc-yank)
2127 (while (and (setq a (cdr a)) 2061 (while (and (setq a (cdr a))
2128 (Math-vectorp (car a)) 2062 (Math-vectorp (car a))
2129 (= (length (car a)) len))) 2063 (= (length (car a)) len)))
2130 (null a))) 2064 (null a))))
2131)
2132 2065
2133(defun math-matrixp-step (a len) ; [P L] 2066(defun math-matrixp-step (a len) ; [P L]
2134 (or (null a) 2067 (or (null a)
2135 (and (Math-vectorp (car a)) 2068 (and (Math-vectorp (car a))
2136 (= (length (car a)) len) 2069 (= (length (car a)) len)
2137 (math-matrixp-step (cdr a) len))) 2070 (math-matrixp-step (cdr a) len))))
2138)
2139 2071
2140;;; True if A is a square matrix. [P V] [Public] 2072;;; True if A is a square matrix. [P V] [Public]
2141(defun math-square-matrixp (a) 2073(defun math-square-matrixp (a)
2142 (let ((dims (math-mat-dimens a))) 2074 (let ((dims (math-mat-dimens a)))
2143 (and (cdr dims) 2075 (and (cdr dims)
2144 (= (car dims) (nth 1 dims)))) 2076 (= (car dims) (nth 1 dims)))))
2145)
2146 2077
2147;;; True if A is any scalar data object. [P x] 2078;;; True if A is any scalar data object. [P x]
2148(defun math-objectp (a) ; [Public] 2079(defun math-objectp (a) ; [Public]
2149 (or (integerp a) 2080 (or (integerp a)
2150 (memq (car-safe a) '(bigpos bigneg frac float cplx 2081 (memq (car-safe a) '(bigpos bigneg frac float cplx
2151 polar hms date sdev intv mod))) 2082 polar hms date sdev intv mod))))
2152)
2153 2083
2154;;; Verify that A is an integer and return A in integer form. [I N; - x] 2084;;; Verify that A is an integer and return A in integer form. [I N; - x]
2155(defun math-check-integer (a) ; [Public] 2085(defun math-check-integer (a) ; [Public]
@@ -2157,8 +2087,7 @@ calc-kill calc-kill-region calc-yank)
2157 ((math-integerp a) a) 2087 ((math-integerp a) a)
2158 ((math-messy-integerp a) 2088 ((math-messy-integerp a)
2159 (math-trunc a)) 2089 (math-trunc a))
2160 (t (math-reject-arg a 'integerp))) 2090 (t (math-reject-arg a 'integerp))))
2161)
2162 2091
2163;;; Verify that A is a small integer and return A in integer form. [S N; - x] 2092;;; Verify that A is a small integer and return A in integer form. [S N; - x]
2164(defun math-check-fixnum (a &optional allow-inf) ; [Public] 2093(defun math-check-fixnum (a &optional allow-inf) ; [Public]
@@ -2175,8 +2104,7 @@ calc-kill calc-kill-region calc-yank)
2175 (lsh -1 -1)) 2104 (lsh -1 -1))
2176 ((and allow-inf (equal a '(neg (var inf var-inf)))) 2105 ((and allow-inf (equal a '(neg (var inf var-inf))))
2177 (- (lsh -1 -1))) 2106 (- (lsh -1 -1)))
2178 (t (math-reject-arg a 'fixnump))) 2107 (t (math-reject-arg a 'fixnump))))
2179)
2180 2108
2181;;; Verify that A is an integer >= 0 and return A in integer form. [I N; - x] 2109;;; Verify that A is an integer >= 0 and return A in integer form. [I N; - x]
2182(defun math-check-natnum (a) ; [Public] 2110(defun math-check-natnum (a) ; [Public]
@@ -2184,24 +2112,21 @@ calc-kill calc-kill-region calc-yank)
2184 ((and (not (math-negp a)) 2112 ((and (not (math-negp a))
2185 (Math-num-integerp a)) 2113 (Math-num-integerp a))
2186 (math-trunc a)) 2114 (math-trunc a))
2187 (t (math-reject-arg a 'natnump))) 2115 (t (math-reject-arg a 'natnump))))
2188)
2189 2116
2190;;; Verify that A is in floating-point form, or force it to be a float. [F N] 2117;;; Verify that A is in floating-point form, or force it to be a float. [F N]
2191(defun math-check-float (a) ; [Public] 2118(defun math-check-float (a) ; [Public]
2192 (cond ((eq (car-safe a) 'float) a) 2119 (cond ((eq (car-safe a) 'float) a)
2193 ((Math-vectorp a) (math-map-vec 'math-check-float a)) 2120 ((Math-vectorp a) (math-map-vec 'math-check-float a))
2194 ((Math-objectp a) (math-float a)) 2121 ((Math-objectp a) (math-float a))
2195 (t a)) 2122 (t a)))
2196)
2197 2123
2198;;; Verify that A is a constant. 2124;;; Verify that A is a constant.
2199(defun math-check-const (a &optional exp-ok) 2125(defun math-check-const (a &optional exp-ok)
2200 (if (or (math-constp a) 2126 (if (or (math-constp a)
2201 (and exp-ok math-expand-formulas)) 2127 (and exp-ok math-expand-formulas))
2202 a 2128 a
2203 (math-reject-arg a 'constp)) 2129 (math-reject-arg a 'constp)))
2204)
2205 2130
2206 2131
2207;;; Coerce integer A to be a small integer. [S I] 2132;;; Coerce integer A to be a small integer. [S I]
@@ -2212,14 +2137,12 @@ calc-kill calc-kill-region calc-yank)
2212 (- (math-fixnum-big (cdr a))) 2137 (- (math-fixnum-big (cdr a)))
2213 (math-fixnum-big (cdr a))) 2138 (math-fixnum-big (cdr a)))
2214 0) 2139 0)
2215 a) 2140 a))
2216)
2217 2141
2218(defun math-fixnum-big (a) 2142(defun math-fixnum-big (a)
2219 (if (cdr a) 2143 (if (cdr a)
2220 (+ (car a) (* (math-fixnum-big (cdr a)) 1000)) 2144 (+ (car a) (* (math-fixnum-big (cdr a)) 1000))
2221 (car a)) 2145 (car a)))
2222)
2223 2146
2224 2147
2225(defun math-normalize-fancy (a) 2148(defun math-normalize-fancy (a)
@@ -2289,8 +2212,7 @@ calc-kill calc-kill-region calc-yank)
2289 ((or (integerp (car a)) (consp (car a))) 2212 ((or (integerp (car a)) (consp (car a)))
2290 (if (null (cdr a)) 2213 (if (null (cdr a))
2291 (math-normalize (car a)) 2214 (math-normalize (car a))
2292 (error "Can't use multi-valued function in an expression")))) 2215 (error "Can't use multi-valued function in an expression")))))
2293)
2294 2216
2295(defun math-normalize-nonstandard () ; uses "a" 2217(defun math-normalize-nonstandard () ; uses "a"
2296 (if (consp calc-simplify-mode) 2218 (if (consp calc-simplify-mode)
@@ -2307,8 +2229,7 @@ calc-kill calc-kill-region calc-yank)
2307 (while (and aptr (math-constp (car aptr))) 2229 (while (and aptr (math-constp (car aptr)))
2308 (setq aptr (cdr aptr))) 2230 (setq aptr (cdr aptr)))
2309 aptr))) 2231 aptr)))
2310 (cons (car a) (mapcar 'math-normalize (cdr a))))) 2232 (cons (car a) (mapcar 'math-normalize (cdr a))))))
2311)
2312 2233
2313 2234
2314 2235
@@ -2324,14 +2245,12 @@ calc-kill calc-kill-region calc-yank)
2324 (and last 2245 (and last
2325 (progn 2246 (progn
2326 (setcdr last nil) 2247 (setcdr last nil)
2327 a))) 2248 a))))
2328)
2329 2249
2330(defun math-bignum-test (a) ; [B N; B s; b b] 2250(defun math-bignum-test (a) ; [B N; B s; b b]
2331 (if (consp a) 2251 (if (consp a)
2332 a 2252 a
2333 (math-bignum a)) 2253 (math-bignum a)))
2334)
2335 2254
2336 2255
2337;;; Return 0 for zero, -1 for negative, 1 for positive. [S n] [Public] 2256;;; Return 0 for zero, -1 for negative, 1 for positive. [S n] [Public]
@@ -2344,8 +2263,7 @@ calc-kill calc-kill-region calc-yank)
2344 (t (calc-record-why 'realp a) 2263 (t (calc-record-why 'realp a)
2345 (if x 2264 (if x
2346 (list 'calcFunc-sign a x) 2265 (list 'calcFunc-sign a x)
2347 (list 'calcFunc-sign a))))) 2266 (list 'calcFunc-sign a))))))
2348)
2349 2267
2350;;; Return 0 if A is numerically equal to B, <0 if less, >0 if more. 2268;;; Return 0 if A is numerically equal to B, <0 if less, >0 if more.
2351;;; Arguments must be normalized! [S N N] 2269;;; Arguments must be normalized! [S N N]
@@ -2457,8 +2375,7 @@ calc-kill calc-kill-region calc-yank)
2457 (eq (car a) (car b)) 2375 (eq (car a) (car b))
2458 (math-compare-lists (cdr a) (cdr b))) 2376 (math-compare-lists (cdr a) (cdr b)))
2459 0 2377 0
2460 2))) 2378 2))))
2461)
2462 2379
2463;;; Compare two bignum digit lists, return -1 for A<B, 0 for A=B, 1 for A>B. 2380;;; Compare two bignum digit lists, return -1 for A<B, 0 for A=B, 1 for A>B.
2464(defun math-compare-bignum (a b) ; [S l l] 2381(defun math-compare-bignum (a b) ; [S l l]
@@ -2475,15 +2392,13 @@ calc-kill calc-kill-region calc-yank)
2475 (while (eq (car a) 0) (setq a (cdr a))) 2392 (while (eq (car a) 0) (setq a (cdr a)))
2476 (if a 1 res)) 2393 (if a 1 res))
2477 (while (eq (car b) 0) (setq b (cdr b))) 2394 (while (eq (car b) 0) (setq b (cdr b)))
2478 (if b -1 res))) 2395 (if b -1 res))))
2479)
2480 2396
2481(defun math-compare-lists (a b) 2397(defun math-compare-lists (a b)
2482 (cond ((null a) (null b)) 2398 (cond ((null a) (null b))
2483 ((null b) nil) 2399 ((null b) nil)
2484 (t (and (Math-equal (car a) (car b)) 2400 (t (and (Math-equal (car a) (car b))
2485 (math-compare-lists (cdr a) (cdr b))))) 2401 (math-compare-lists (cdr a) (cdr b))))))
2486)
2487 2402
2488(defun math-lessp-float (a b) ; [P F F] 2403(defun math-lessp-float (a b) ; [P F F]
2489 (let ((ediff (- (nth 2 a) (nth 2 b)))) 2404 (let ((ediff (- (nth 2 a) (nth 2 b))))
@@ -2500,18 +2415,15 @@ calc-kill calc-kill-region calc-yank)
2500 (Math-integer-negp (nth 1 a)) 2415 (Math-integer-negp (nth 1 a))
2501 (Math-integer-posp (nth 1 b))) 2416 (Math-integer-posp (nth 1 b)))
2502 (Math-lessp (nth 1 a) 2417 (Math-lessp (nth 1 a)
2503 (math-scale-int (nth 1 b) ediff))))) 2418 (math-scale-int (nth 1 b) ediff))))))
2504)
2505 2419
2506;;; True if A is numerically equal to B. [P N N] [Public] 2420;;; True if A is numerically equal to B. [P N N] [Public]
2507(defun math-equal (a b) 2421(defun math-equal (a b)
2508 (= (math-compare a b) 0) 2422 (= (math-compare a b) 0))
2509)
2510 2423
2511;;; True if A is numerically less than B. [P R R] [Public] 2424;;; True if A is numerically less than B. [P R R] [Public]
2512(defun math-lessp (a b) 2425(defun math-lessp (a b)
2513 (= (math-compare a b) -1) 2426 (= (math-compare a b) -1))
2514)
2515 2427
2516;;; True if A is numerically equal to the integer B. [P N S] [Public] 2428;;; True if A is numerically equal to the integer B. [P N S] [Public]
2517;;; B must not be a multiple of 10. 2429;;; B must not be a multiple of 10.
@@ -2519,8 +2431,7 @@ calc-kill calc-kill-region calc-yank)
2519 (or (eq a b) 2431 (or (eq a b)
2520 (and (eq (car-safe a) 'float) 2432 (and (eq (car-safe a) 'float)
2521 (eq (nth 1 a) b) 2433 (eq (nth 1 a) b)
2522 (= (nth 2 a) 0))) 2434 (= (nth 2 a) 0))))
2523)
2524 2435
2525 2436
2526 2437
@@ -2532,8 +2443,7 @@ calc-kill calc-kill-region calc-yank)
2532 (cons (1- (length m)) 2443 (cons (1- (length m))
2533 (math-mat-dimens (nth 1 m))) 2444 (math-mat-dimens (nth 1 m)))
2534 (list (1- (length m)))) 2445 (list (1- (length m))))
2535 nil) 2446 nil))
2536)
2537 2447
2538 2448
2539 2449
@@ -2559,8 +2469,7 @@ calc-kill calc-kill-region calc-yank)
2559 (mapcar (function 2469 (mapcar (function
2560 (lambda (x) 2470 (lambda (x)
2561 (list func x rhs))) 2471 (list func x rhs)))
2562 (calc-top-list-n (- n) 2))))))) 2472 (calc-top-list-n (- n) 2))))))))
2563)
2564 2473
2565(defun calc-unary-op-fancy (name func arg) 2474(defun calc-unary-op-fancy (name func arg)
2566 (let ((n (prefix-numeric-value arg))) 2475 (let ((n (prefix-numeric-value arg)))
@@ -2576,8 +2485,7 @@ calc-kill calc-kill-region calc-yank)
2576 (calc-enter-result 1 2485 (calc-enter-result 1
2577 name 2486 name
2578 (list func (calc-top-n (- n))) 2487 (list func (calc-top-n (- n)))
2579 (- n))))) 2488 (- n))))))
2580)
2581 2489
2582 2490
2583 2491
@@ -2593,18 +2501,15 @@ calc-kill calc-kill-region calc-yank)
2593 2501
2594(defun math-inexact-result () 2502(defun math-inexact-result ()
2595 (and calc-symbolic-mode 2503 (and calc-symbolic-mode
2596 (signal 'inexact-result nil)) 2504 (signal 'inexact-result nil)))
2597)
2598 2505
2599(defun math-overflow (&optional exp) 2506(defun math-overflow (&optional exp)
2600 (if (and exp (math-negp exp)) 2507 (if (and exp (math-negp exp))
2601 (math-underflow) 2508 (math-underflow)
2602 (signal 'math-overflow nil)) 2509 (signal 'math-overflow nil)))
2603)
2604 2510
2605(defun math-underflow () 2511(defun math-underflow ()
2606 (signal 'math-underflow nil) 2512 (signal 'math-underflow nil))
2607)
2608 2513
2609 2514
2610 2515
@@ -2637,8 +2542,7 @@ calc-kill calc-kill-region calc-yank)
2637 (setq c b 2542 (setq c b
2638 b (% a b) 2543 b (% a b)
2639 a c)) 2544 a c))
2640 a))) 2545 a))))
2641)
2642 2546
2643 2547
2644;;;; Algebra. 2548;;;; Algebra.
@@ -2647,9 +2551,9 @@ calc-kill calc-kill-region calc-yank)
2647(defun math-evaluate-expr (x) ; [Public] 2551(defun math-evaluate-expr (x) ; [Public]
2648 (if calc-embedded-info 2552 (if calc-embedded-info
2649 (calc-embedded-evaluate-expr x) 2553 (calc-embedded-evaluate-expr x)
2650 (calc-normalize (math-evaluate-expr-rec x))) 2554 (calc-normalize (math-evaluate-expr-rec x))))
2651) 2555
2652(fset 'calcFunc-evalv (symbol-function 'math-evaluate-expr)) 2556(defalias 'calcFunc-evalv 'math-evaluate-expr)
2653 2557
2654(defun calcFunc-evalvn (x &optional prec) 2558(defun calcFunc-evalvn (x &optional prec)
2655 (if prec 2559 (if prec
@@ -2669,8 +2573,7 @@ calc-kill calc-kill-region calc-yank)
2669 (let ((calc-internal-prec prec)) 2573 (let ((calc-internal-prec prec))
2670 (calcFunc-evalvn x)))) 2574 (calcFunc-evalvn x))))
2671 (let ((calc-symbolic-mode nil)) 2575 (let ((calc-symbolic-mode nil))
2672 (math-evaluate-expr x))) 2576 (math-evaluate-expr x))))
2673)
2674 2577
2675(defun math-evaluate-expr-rec (x) 2578(defun math-evaluate-expr-rec (x)
2676 (if (consp x) 2579 (if (consp x)
@@ -2694,18 +2597,12 @@ calc-kill calc-kill-region calc-yank)
2694 (if (Math-primp x) 2597 (if (Math-primp x)
2695 x 2598 x
2696 (cons (car x) (mapcar 'math-evaluate-expr-rec (cdr x)))))) 2599 (cons (car x) (mapcar 'math-evaluate-expr-rec (cdr x))))))
2697 x) 2600 x))
2698)
2699
2700
2701 2601
2702(setq math-simplifying nil) 2602(setq math-simplifying nil)
2703(setq math-living-dangerously nil) ; true if unsafe simplifications are okay. 2603(setq math-living-dangerously nil) ; true if unsafe simplifications are okay.
2704(setq math-integrating nil) 2604(setq math-integrating nil)
2705 2605
2706
2707
2708
2709(defmacro math-defsimplify (funcs &rest code) 2606(defmacro math-defsimplify (funcs &rest code)
2710 (append '(progn (math-need-std-simps)) 2607 (append '(progn (math-need-std-simps))
2711 (mapcar (function 2608 (mapcar (function
@@ -2717,26 +2614,20 @@ calc-kill calc-kill-region calc-yank)
2717 (list 'function 2614 (list 'function
2718 (append '(lambda (expr)) 2615 (append '(lambda (expr))
2719 code))))))) 2616 code)))))))
2720 (if (symbolp funcs) (list funcs) funcs))) 2617 (if (symbolp funcs) (list funcs) funcs))))
2721)
2722(put 'math-defsimplify 'lisp-indent-hook 1) 2618(put 'math-defsimplify 'lisp-indent-hook 1)
2723 2619
2724
2725(defun math-any-floats (expr) 2620(defun math-any-floats (expr)
2726 (if (Math-primp expr) 2621 (if (Math-primp expr)
2727 (math-floatp expr) 2622 (math-floatp expr)
2728 (while (and (setq expr (cdr expr)) (not (math-any-floats (car expr))))) 2623 (while (and (setq expr (cdr expr)) (not (math-any-floats (car expr)))))
2729 expr) 2624 expr))
2730)
2731 2625
2732(defvar var-FactorRules 'calc-FactorRules) 2626(defvar var-FactorRules 'calc-FactorRules)
2733 2627
2734
2735
2736(defun math-map-tree (mmt-func mmt-expr &optional mmt-many) 2628(defun math-map-tree (mmt-func mmt-expr &optional mmt-many)
2737 (or mmt-many (setq mmt-many 1000000)) 2629 (or mmt-many (setq mmt-many 1000000))
2738 (math-map-tree-rec mmt-expr) 2630 (math-map-tree-rec mmt-expr))
2739)
2740 2631
2741(defun math-map-tree-rec (mmt-expr) 2632(defun math-map-tree-rec (mmt-expr)
2742 (or (= mmt-many 0) 2633 (or (= mmt-many 0)
@@ -2757,19 +2648,14 @@ calc-kill calc-kill-region calc-yank)
2757 (if (equal mmt-nextval mmt-expr) 2648 (if (equal mmt-nextval mmt-expr)
2758 (setq mmt-done t) 2649 (setq mmt-done t)
2759 (setq mmt-expr mmt-nextval)))))) 2650 (setq mmt-expr mmt-nextval))))))
2760 mmt-expr 2651 mmt-expr)
2761)
2762
2763
2764
2765 2652
2766(setq math-rewrite-selections nil) 2653(setq math-rewrite-selections nil)
2767 2654
2768(defun math-is-true (expr) 2655(defun math-is-true (expr)
2769 (if (Math-numberp expr) 2656 (if (Math-numberp expr)
2770 (not (Math-zerop expr)) 2657 (not (Math-zerop expr))
2771 (math-known-nonzerop expr)) 2658 (math-known-nonzerop expr)))
2772)
2773 2659
2774(defun math-const-var (expr) 2660(defun math-const-var (expr)
2775 (and (consp expr) 2661 (and (consp expr)
@@ -2777,11 +2663,7 @@ calc-kill calc-kill-region calc-yank)
2777 (or (and (symbolp (nth 2 expr)) 2663 (or (and (symbolp (nth 2 expr))
2778 (boundp (nth 2 expr)) 2664 (boundp (nth 2 expr))
2779 (eq (car-safe (symbol-value (nth 2 expr))) 'special-const)) 2665 (eq (car-safe (symbol-value (nth 2 expr))) 'special-const))
2780 (memq (nth 2 expr) '(var-inf var-uinf var-nan)))) 2666 (memq (nth 2 expr) '(var-inf var-uinf var-nan)))))
2781)
2782
2783
2784
2785 2667
2786(defmacro math-defintegral (funcs &rest code) 2668(defmacro math-defintegral (funcs &rest code)
2787 (setq math-integral-cache nil) 2669 (setq math-integral-cache nil)
@@ -2795,8 +2677,7 @@ calc-kill calc-kill-region calc-yank)
2795 (list 'function 2677 (list 'function
2796 (append '(lambda (u)) 2678 (append '(lambda (u))
2797 code))))))) 2679 code)))))))
2798 (if (symbolp funcs) (list funcs) funcs))) 2680 (if (symbolp funcs) (list funcs) funcs))))
2799)
2800(put 'math-defintegral 'lisp-indent-hook 1) 2681(put 'math-defintegral 'lisp-indent-hook 1)
2801 2682
2802(defmacro math-defintegral-2 (funcs &rest code) 2683(defmacro math-defintegral-2 (funcs &rest code)
@@ -2812,33 +2693,25 @@ calc-kill calc-kill-region calc-yank)
2812 (list 'function 2693 (list 'function
2813 (append '(lambda (u v)) 2694 (append '(lambda (u v))
2814 code))))))) 2695 code)))))))
2815 (if (symbolp funcs) (list funcs) funcs))) 2696 (if (symbolp funcs) (list funcs) funcs))))
2816)
2817(put 'math-defintegral-2 'lisp-indent-hook 1) 2697(put 'math-defintegral-2 'lisp-indent-hook 1)
2818 2698
2819
2820(defvar var-IntegAfterRules 'calc-IntegAfterRules) 2699(defvar var-IntegAfterRules 'calc-IntegAfterRules)
2821 2700
2822
2823(defvar var-FitRules 'calc-FitRules) 2701(defvar var-FitRules 'calc-FitRules)
2824 2702
2825
2826(setq math-poly-base-variable nil) 2703(setq math-poly-base-variable nil)
2827(setq math-poly-neg-powers nil) 2704(setq math-poly-neg-powers nil)
2828(setq math-poly-mult-powers 1) 2705(setq math-poly-mult-powers 1)
2829(setq math-poly-frac-powers nil) 2706(setq math-poly-frac-powers nil)
2830(setq math-poly-exp-base nil) 2707(setq math-poly-exp-base nil)
2831 2708
2832
2833
2834
2835(defun math-build-var-name (name) 2709(defun math-build-var-name (name)
2836 (if (stringp name) 2710 (if (stringp name)
2837 (setq name (intern name))) 2711 (setq name (intern name)))
2838 (if (string-match "\\`var-." (symbol-name name)) 2712 (if (string-match "\\`var-." (symbol-name name))
2839 (list 'var (intern (substring (symbol-name name) 4)) name) 2713 (list 'var (intern (substring (symbol-name name) 4)) name)
2840 (list 'var name (intern (concat "var-" (symbol-name name))))) 2714 (list 'var name (intern (concat "var-" (symbol-name name))))))
2841)
2842 2715
2843(setq math-simplifying-units nil) 2716(setq math-simplifying-units nil)
2844(setq math-combining-units t) 2717(setq math-combining-units t)
@@ -3007,8 +2880,7 @@ calc-kill calc-kill-region calc-yank)
3007 (math-match-substring s 2)))) 2880 (math-match-substring s 2))))
3008 2881
3009 ;; Syntax error! 2882 ;; Syntax error!
3010 (t nil)) 2883 (t nil)))
3011)
3012 2884
3013(defun math-read-radix (s r) ; [I X D] 2885(defun math-read-radix (s r) ; [I X D]
3014 (setq s (upcase s)) 2886 (setq s (upcase s))
@@ -3021,8 +2893,7 @@ calc-kill calc-kill-region calc-yank)
3021 (setq res (math-add (math-mul res r) dig) 2893 (setq res (math-add (math-mul res r) dig)
3022 i (1+ i))) 2894 i (1+ i)))
3023 (and (= i (length s)) 2895 (and (= i (length s))
3024 res)) 2896 res)))
3025)
3026 2897
3027 2898
3028 2899
@@ -3043,8 +2914,7 @@ calc-kill calc-kill-region calc-yank)
3043 (list 'error exp-old-pos val) 2914 (list 'error exp-old-pos val)
3044 (if (equal exp-token 'end) 2915 (if (equal exp-token 'end)
3045 val 2916 val
3046 (list 'error exp-old-pos "Syntax error"))))) 2917 (list 'error exp-old-pos "Syntax error"))))))
3047)
3048 2918
3049(defun math-read-plain-expr (exp-str &optional error-check) 2919(defun math-read-plain-expr (exp-str &optional error-check)
3050 (let* ((calc-language nil) 2920 (let* ((calc-language nil)
@@ -3053,8 +2923,7 @@ calc-kill calc-kill-region calc-yank)
3053 (and error-check 2923 (and error-check
3054 (eq (car-safe val) 'error) 2924 (eq (car-safe val) 'error)
3055 (error "%s: %s" (nth 2 val) exp-str)) 2925 (error "%s: %s" (nth 2 val) exp-str))
3056 val) 2926 val))
3057)
3058 2927
3059 2928
3060(defun math-read-string () 2929(defun math-read-string ()
@@ -3063,8 +2932,7 @@ calc-kill calc-kill-region calc-yank)
3063 (stringp (car str))) 2932 (stringp (car str)))
3064 (throw 'syntax "Error in string constant")) 2933 (throw 'syntax "Error in string constant"))
3065 (math-read-token) 2934 (math-read-token)
3066 (append '(vec) (car str) nil)) 2935 (append '(vec) (car str) nil)))
3067)
3068 2936
3069 2937
3070 2938
@@ -3107,8 +2975,7 @@ calc-kill calc-kill-region calc-yank)
3107 (math-read-big-rec 0 0 width (length lines))) 2975 (math-read-big-rec 0 0 width (length lines)))
3108 err-msg 2976 err-msg
3109 '(error 0 "Syntax error")) 2977 '(error 0 "Syntax error"))
3110 (math-read-expr str)))) 2978 (math-read-expr str)))))
3111)
3112 2979
3113(defun math-read-big-bigp (lines) 2980(defun math-read-big-bigp (lines)
3114 (and (cdr lines) 2981 (and (cdr lines)
@@ -3144,8 +3011,7 @@ calc-kill calc-kill-region calc-yank)
3144 v (1+ v))) 3011 v (1+ v)))
3145 (or (and (> height 1) 3012 (or (and (> height 1)
3146 (not (cdr lines))) 3013 (not (cdr lines)))
3147 matrix))) 3014 matrix))))
3148)
3149 3015
3150 3016
3151 3017
@@ -3227,8 +3093,7 @@ calc-kill calc-kill-region calc-yank)
3227 (symbol-name (car a)))) 3093 (symbol-name (car a))))
3228 "(" 3094 "("
3229 (math-format-flat-vector (cdr a) ", " 0) 3095 (math-format-flat-vector (cdr a) ", " 0)
3230 ")")))))) 3096 ")")))))))
3231)
3232(setq math-format-hash-args nil) 3097(setq math-format-hash-args nil)
3233 3098
3234(defun math-format-flat-vector (vec sep prec) 3099(defun math-format-flat-vector (vec sep prec)
@@ -3237,8 +3102,7 @@ calc-kill calc-kill-region calc-yank)
3237 (while (setq vec (cdr vec)) 3102 (while (setq vec (cdr vec))
3238 (setq buf (concat buf sep (math-format-flat-expr (car vec) prec)))) 3103 (setq buf (concat buf sep (math-format-flat-expr (car vec) prec))))
3239 buf) 3104 buf)
3240 "") 3105 ""))
3241)
3242(setq calc-can-abbrev-vectors nil) 3106(setq calc-can-abbrev-vectors nil)
3243 3107
3244(defun math-format-nice-expr (x w) 3108(defun math-format-nice-expr (x w)
@@ -3265,14 +3129,12 @@ calc-kill calc-kill-region calc-yank)
3265 (substring str p)) 3129 (substring str p))
3266 pos (1+ p)) 3130 pos (1+ p))
3267 (setq pos (+ pos w))))) 3131 (setq pos (+ pos w)))))
3268 str))) 3132 str))))
3269)
3270 3133
3271(defun math-assq2 (v a) 3134(defun math-assq2 (v a)
3272 (while (and a (not (eq v (nth 1 (car a))))) 3135 (while (and a (not (eq v (nth 1 (car a)))))
3273 (setq a (cdr a))) 3136 (setq a (cdr a)))
3274 (car a) 3137 (car a))
3275)
3276 3138
3277 3139
3278(defun math-format-number-fancy (a prec) 3140(defun math-format-number-fancy (a prec)
@@ -3363,8 +3225,7 @@ calc-kill calc-kill-region calc-yank)
3363 (math-format-number (nth 2 a)))) 3225 (math-format-number (nth 2 a))))
3364 ((eq (car a) 'vec) 3226 ((eq (car a) 'vec)
3365 (math-format-flat-expr a 0)) 3227 (math-format-flat-expr a 0))
3366 (t (format "%s" a))) 3228 (t (format "%s" a))))
3367)
3368 3229
3369(defun math-adjust-fraction (a) 3230(defun math-adjust-fraction (a)
3370 (if (nth 1 calc-frac-format) 3231 (if (nth 1 calc-frac-format)
@@ -3374,8 +3235,7 @@ calc-kill calc-kill-region calc-yank)
3374 (math-gcd (nth 2 a) 3235 (math-gcd (nth 2 a)
3375 (nth 1 calc-frac-format))))) 3236 (nth 1 calc-frac-format)))))
3376 (list 'frac (math-mul (nth 1 a) g) (math-mul (nth 2 a) g)))) 3237 (list 'frac (math-mul (nth 1 a) g) (math-mul (nth 2 a) g))))
3377 a) 3238 a))
3378)
3379 3239
3380(defun math-format-bignum-fancy (a) ; [X L] 3240(defun math-format-bignum-fancy (a) ; [X L]
3381 (let ((str (cond ((= calc-number-radix 10) 3241 (let ((str (cond ((= calc-number-radix 10)
@@ -3410,8 +3270,7 @@ calc-kill calc-kill-region calc-yank)
3410 (if calc-radix-formatter 3270 (if calc-radix-formatter
3411 (funcall calc-radix-formatter calc-number-radix str) 3271 (funcall calc-radix-formatter calc-number-radix str)
3412 (format "%d#%s" calc-number-radix str)) 3272 (format "%d#%s" calc-number-radix str))
3413 str)) 3273 str)))
3414)
3415 3274
3416 3275
3417(defun math-group-float (str) ; [X X] 3276(defun math-group-float (str) ; [X X]
@@ -3430,15 +3289,7 @@ calc-kill calc-kill-region calc-yank)
3430 str (concat (substring str 0 i) 3289 str (concat (substring str 0 i)
3431 calc-group-char 3290 calc-group-char
3432 (substring str i)))) 3291 (substring str i))))
3433 str) 3292 str))
3434)
3435
3436
3437
3438
3439
3440
3441
3442 3293
3443(setq math-compose-level 0) 3294(setq math-compose-level 0)
3444(setq math-comp-selected nil) 3295(setq math-comp-selected nil)
@@ -3459,10 +3310,8 @@ A command spec is a command name symbol, a keyboard macro string, a
3459list containing a numeric entry string, or nil. 3310list containing a numeric entry string, or nil.
3460A key may contain additional specs for Inverse, Hyperbolic, and Inv+Hyp.") 3311A key may contain additional specs for Inverse, Hyperbolic, and Inv+Hyp.")
3461 3312
3462
3463
3464
3465
3466(run-hooks 'calc-ext-load-hook) 3313(run-hooks 'calc-ext-load-hook)
3467 3314
3315;;; calc-ext.el ends here
3316
3468 3317