annotate lisp/calc/calc-misc.el @ 105630:e2e6510fb5ca

*** empty log message ***
author Juanma Barranquero <lekktu@gmail.com>
date Fri, 16 Oct 2009 04:32:23 +0000
parents e3187820f169
children 1d1d5d9bd884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
63610
48c403ccead5 Fix typo in title.
Juanma Barranquero <lekktu@gmail.com>
parents: 62829
diff changeset
1 ;;; calc-misc.el --- miscellaneous functions for Calc
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
2
64325
1db49616ce05 Update copyright information.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 63610
diff changeset
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 97463
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
5
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
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
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10
94654
6c9af2bfcfee Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93880
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: 93880
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: 93880
diff changeset
14 ;; (at your option) any later version.
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
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: 93880
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
24 ;;; Commentary:
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
25
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
26 ;;; Code:
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28 ;; This file is autoloaded from calc.el.
58664
f23c98cc77a1 Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58613
diff changeset
29
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30 (require 'calc)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31 (require 'calc-macs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32
86477
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
33 ;; Declare functions which are defined elsewhere.
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
34 (declare-function calc-do-keypad "calc-keypd" (&optional full-display interactive))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
35 (declare-function calc-inv-hyp-prefix-help "calc-help" ())
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
36 (declare-function calc-inverse-prefix-help "calc-help" ())
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
37 (declare-function calc-hyperbolic-prefix-help "calc-help" ())
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
38 (declare-function calc-explain-why "calc-stuff" (why &optional more))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
39 (declare-function calc-clear-command-flag "calc-ext" (f))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
40 (declare-function calc-roll-down-with-selections "calc-sel" (n m))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
41 (declare-function calc-roll-up-with-selections "calc-sel" (n m))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
42 (declare-function calc-last-args "calc-undo" (n))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
43 (declare-function calc-is-inverse "calc-ext" ())
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
44 (declare-function calc-do-prefix-help "calc-ext" (msgs group key))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
45 (declare-function math-objvecp "calc-ext" (a))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
46 (declare-function math-known-scalarp "calc-arith" (a &optional assume-scalar))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
47 (declare-function math-vectorp "calc-ext" (a))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
48 (declare-function math-matrixp "calc-ext" (a))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
49 (declare-function math-trunc-special "calc-arith" (a prec))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
50 (declare-function math-trunc-fancy "calc-arith" (a))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
51 (declare-function math-floor-special "calc-arith" (a prec))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
52 (declare-function math-floor-fancy "calc-arith" (a))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
53 (declare-function math-square-matrixp "calc-ext" (a))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
54 (declare-function math-matrix-inv-raw "calc-mtx" (m))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
55 (declare-function math-known-matrixp "calc-arith" (a))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
56 (declare-function math-mod-fancy "calc-arith" (a b))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
57 (declare-function math-pow-of-zero "calc-arith" (a b))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
58 (declare-function math-pow-zero "calc-arith" (a b))
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
59 (declare-function math-pow-fancy "calc-arith" (a b))
104099
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
60 (declare-function calc-locate-cursor-element "calc-yank" (pt))
86477
327601aefd65 (calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 84888
diff changeset
61
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
62 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
63 (defun calc-dispatch-help (arg)
67190
655ce2fe3aa6 (calc-dispatch-help): Update docstring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 66480
diff changeset
64 "C-x* is a prefix key sequence; follow it with one of these letters:
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
65
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
66 For turning Calc on and off:
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
67 C calc. Start the Calculator in a window at the bottom of the screen.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
68 O calc-other-window. Start the Calculator but don't select its window.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
69 B calc-big-or-small. Control whether to use the full Emacs screen for Calc.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
70 Q quick-calc. Use the Calculator in the minibuffer.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
71 K calc-keypad. Start the Calculator in keypad mode (X window system only).
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
72 E calc-embedded. Use the Calculator on a formula in this editing buffer.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
73 J calc-embedded-select. Like E, but select appropriate half of => or :=.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
74 W calc-embedded-word. Like E, but activate a single word, i.e., a number.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
75 Z calc-user-invocation. Invoke Calc in the way you defined with `Z I' cmd.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
76 X calc-quit. Turn Calc off.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
77
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
78 For moving data into and out of Calc:
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
79 G calc-grab-region. Grab the region defined by mark and point into Calc.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
80 R calc-grab-rectangle. Grab the rectangle defined by mark, point into Calc.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
81 : calc-grab-sum-down. Grab a rectangle and sum the columns.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
82 _ calc-grab-sum-across. Grab a rectangle and sum the rows.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
83 Y calc-copy-to-buffer. Copy a value from the stack into the editing buffer.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
84
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
85 For use with Embedded mode:
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
86 A calc-embedded-activate. Find and activate all :='s and =>'s in buffer.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
87 D calc-embedded-duplicate. Make a copy of this formula and select it.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
88 F calc-embedded-new-formula. Insert a new formula at current point.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
89 N calc-embedded-next. Advance cursor to next known formula in buffer.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
90 P calc-embedded-previous. Advance cursor to previous known formula.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
91 U calc-embedded-update-formula. Re-evaluate formula at point.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
92 ` calc-embedded-edit. Use calc-edit to edit formula at point.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
93
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
94 Documentation:
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
95 I calc-info. Read the Calculator manual in the Emacs Info system.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
96 T calc-tutorial. Run the Calculator Tutorial using the Emacs Info system.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
97 S calc-summary. Read the Summary from the Calculator manual in Info.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
98
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
99 Miscellaneous:
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
100 L calc-load-everything. Load all parts of the Calculator into memory.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
101 M read-kbd-macro. Read a region of keystroke names as a keyboard macro.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
102 0 (zero) calc-reset. Reset Calc stack and modes to default state.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
103
67190
655ce2fe3aa6 (calc-dispatch-help): Update docstring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 66480
diff changeset
104 Press `*' twice (`C-x * *') to turn Calc on or off using the same
655ce2fe3aa6 (calc-dispatch-help): Update docstring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 66480
diff changeset
105 Calc user interface as before (either C-x * C or C-x * K; initially C-x * C).
655ce2fe3aa6 (calc-dispatch-help): Update docstring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 66480
diff changeset
106 "
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
107 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
108 (calc-check-defines)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
109 (if calc-dispatch-help
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
110 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
111 (save-window-excursion
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
112 (describe-function 'calc-dispatch-help)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
113 (let ((win (get-buffer-window "*Help*")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
114 (if win
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
115 (let (key)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
116 (select-window win)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
117 (while (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
118 (message "Calc options: Calc, Keypad, ... %s"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
119 "press SPC, DEL to scroll, C-g to cancel")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
120 (memq (car (setq key (calc-read-key t)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
121 '(? ?\C-h ?\C-? ?\C-v ?\M-v)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
122 (condition-case err
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
123 (if (memq (car key) '(? ?\C-v))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124 (scroll-up)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
125 (scroll-down))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 (error (beep))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
127 (calc-unread-command (cdr key))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128 (calc-do-dispatch nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129 (let ((calc-dispatch-help t))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
130 (calc-do-dispatch arg))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
133 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 (defun calc-big-or-small (arg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 "Toggle Calc between full-screen and regular mode."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137 (let ((cwin (get-buffer-window "*Calculator*"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 (twin (get-buffer-window "*Calc Trail*"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 (kwin (get-buffer-window "*Calc Keypad*")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 (if cwin
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141 (setq calc-full-mode
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 (if kwin
105478
e3187820f169 Use window-full-height-p.
Glenn Morris <rgm@gnu.org>
parents: 104099
diff changeset
143 (and twin (window-full-width-p twin))
e3187820f169 Use window-full-height-p.
Glenn Morris <rgm@gnu.org>
parents: 104099
diff changeset
144 (window-full-height-p cwin))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
145 (setq calc-full-mode (if arg
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146 (> (prefix-numeric-value arg) 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
147 (not calc-full-mode)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148 (if kwin
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 (calc-quit)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
151 (calc-do-keypad calc-full-mode nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
152 (if cwin
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
154 (calc-quit)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
155 (calc nil calc-full-mode nil))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
156 (message (if calc-full-mode
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
157 "Now using full screen for Calc"
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
158 "Now using partial screen for Calc"))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
160 ;;;###autoload
57711
d9073880a6e4 (calc-other-window): Use an extra argument instead of `interactive-p'.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57430
diff changeset
161 (defun calc-other-window (&optional interactive)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
162 "Invoke the Calculator in another window."
57711
d9073880a6e4 (calc-other-window): Use an extra argument instead of `interactive-p'.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57430
diff changeset
163 (interactive "p")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
164 (if (memq major-mode '(calc-mode calc-trail-mode))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
165 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
166 (other-window 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
167 (if (memq major-mode '(calc-mode calc-trail-mode))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
168 (other-window 1)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
169 (if (get-buffer-window "*Calculator*")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170 (calc-quit)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
171 (let ((win (selected-window)))
57711
d9073880a6e4 (calc-other-window): Use an extra argument instead of `interactive-p'.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57430
diff changeset
172 (calc nil win interactive)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
173
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
174 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
175 (defun another-calc ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
176 "Create another, independent Calculator buffer."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178 (if (eq major-mode 'calc-mode)
84888
23f1c8af4174 (another-calc): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents: 82140
diff changeset
179 (mapc (function
23f1c8af4174 (another-calc): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents: 82140
diff changeset
180 (lambda (v)
23f1c8af4174 (another-calc): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents: 82140
diff changeset
181 (set-default v (symbol-value v)))) calc-local-var-list))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
182 (set-buffer (generate-new-buffer "*Calculator*"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
183 (pop-to-buffer (current-buffer))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
184 (calc-mode))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
185
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
186 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
187 (defun calc-info ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
188 "Run the Emacs Info system on the Calculator documentation."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
189 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
190 (select-window (get-largest-window))
41359
5042a5269efd (calc-info): Don't perform voodoo, just (info "Calc").
Colin Walters <walters@gnu.org>
parents: 41267
diff changeset
191 (info "Calc"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
192
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
193 ;;;###autoload
57430
f4e473491598 (calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
194 (defun calc-info-goto-node (node)
f4e473491598 (calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
195 "Go to a node in the Calculator info documentation."
f4e473491598 (calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
196 (interactive)
f4e473491598 (calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
197 (select-window (get-largest-window))
62829
a91bfc189888 (calc-info-goto-node): Use info instead of Info-goto-node.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 62442
diff changeset
198 (info (concat "(Calc)" node)))
57430
f4e473491598 (calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
199
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
200 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
201 (defun calc-tutorial ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
202 "Run the Emacs Info system on the Calculator Tutorial."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
203 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
204 (if (get-buffer-window "*Calculator*")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
205 (calc-quit))
57430
f4e473491598 (calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
206 (calc-info-goto-node "Interactive Tutorial")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
207 (calc-other-window)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
208 (message "Welcome to the Calc Tutorial!"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
209
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
210 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
211 (defun calc-info-summary ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
212 "Run the Emacs Info system on the Calculator Summary."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
213 (interactive)
57430
f4e473491598 (calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
214 (calc-info-goto-node "Summary"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
215
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
216 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
217 (defun calc-help ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
218 (interactive)
97463
c28e1ae0ccfa (report-calc-bug): Remove version number.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 94654
diff changeset
219 (let ((msgs
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
220 '("Press `h' for complete help; press `?' repeatedly for a summary"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
221 "Letter keys: Negate; Precision; Yank; Why; Xtended cmd; Quit"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
222 "Letter keys: SHIFT + Undo, reDo; Keep-args; Inverse, Hyperbolic"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
223 "Letter keys: SHIFT + sQrt; Sin, Cos, Tan; Exp, Ln, logB"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
224 "Letter keys: SHIFT + Floor, Round; Abs, conJ, arG; Pi"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
225 "Letter keys: SHIFT + Num-eval; More-recn; eXec-kbd-macro"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
226 "Other keys: +, -, *, /, ^, \\ (int div), : (frac div)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
227 "Other keys: & (1/x), | (concat), % (modulo), ! (factorial)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
228 "Other keys: ' (alg-entry), = (eval), ` (edit); M-RET (last-args)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
229 "Other keys: SPC/RET (enter/dup), LFD (over); < > (scroll horiz)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
230 "Other keys: DEL (drop), M-DEL (drop-above); { } (scroll vert)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
231 "Other keys: TAB (swap/roll-dn), M-TAB (roll-up)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
232 "Other keys: [ , ; ] (vector), ( , ) (complex), ( ; ) (polar)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
233 "Prefix keys: Algebra, Binary/business, Convert, Display"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
234 "Prefix keys: Functions, Graphics, Help, J (select)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
235 "Prefix keys: Kombinatorics/statistics, Modes, Store/recall"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
236 "Prefix keys: Trail/time, Units/statistics, Vector/matrix"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
237 "Prefix keys: Z (user), SHIFT + Z (define)"
97463
c28e1ae0ccfa (report-calc-bug): Remove version number.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 94654
diff changeset
238 "Prefix keys: prefix + ? gives further help for that prefix"
c28e1ae0ccfa (report-calc-bug): Remove version number.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 94654
diff changeset
239 " Calc by Dave Gillespie, daveg@synaptics.com")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
240 (if calc-full-help-flag
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
241 msgs
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
242 (if (or calc-inverse-flag calc-hyperbolic-flag)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
243 (if calc-inverse-flag
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
244 (if calc-hyperbolic-flag
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
245 (calc-inv-hyp-prefix-help)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
246 (calc-inverse-prefix-help))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
247 (calc-hyperbolic-prefix-help))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
248 (setq calc-help-phase
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
249 (if (eq this-command last-command)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
250 (% (1+ calc-help-phase) (1+ (length msgs)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
251 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
252 (let ((msg (nth calc-help-phase msgs)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
253 (message "%s" (if msg
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
254 (concat msg ":"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
255 (make-string (- (apply 'max
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
256 (mapcar 'length
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
257 msgs))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
258 (length msg)) 32)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
259 " [?=MORE]")
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
260 "")))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
261
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
262
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
263
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
264
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
265 ;;;; Stack and buffer management.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
266
58543
129486947645 (calc-last-why-command): Declare it.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58480
diff changeset
267 ;; The variable calc-last-why-command is set in calc-do-handly-whys
129486947645 (calc-last-why-command): Declare it.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58480
diff changeset
268 ;; and used in calc-why (in calc-stuff.el).
129486947645 (calc-last-why-command): Declare it.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58480
diff changeset
269 (defvar calc-last-why-command)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
270
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
271 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
272 (defun calc-do-handle-whys ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
273 (setq calc-why (sort calc-next-why
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
274 (function
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
275 (lambda (x y)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
276 (and (eq (car x) '*) (not (eq (car y) '*))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
277 calc-next-why nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
278 (if (and calc-why (or (eq calc-auto-why t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
279 (and (eq (car (car calc-why)) '*)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
280 calc-auto-why)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
281 (progn
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
282 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
283 (calc-explain-why (car calc-why)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
284 (if (eq calc-auto-why t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
285 (cdr calc-why)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
286 (if calc-auto-why
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
287 (eq (car (nth 1 calc-why)) '*))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
288 (setq calc-last-why-command this-command)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
289 (calc-clear-command-flag 'clear-message))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
290
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
291 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
292 (defun calc-record-why (&rest stuff)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
293 (if (eq (car stuff) 'quiet)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
294 (setq stuff (cdr stuff))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
295 (if (and (symbolp (car stuff))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
296 (cdr stuff)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
297 (or (Math-objectp (nth 1 stuff))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
298 (and (Math-vectorp (nth 1 stuff))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
299 (math-constp (nth 1 stuff)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
300 (math-infinitep (nth 1 stuff))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
301 (setq stuff (cons '* stuff))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
302 (if (and (stringp (car stuff))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
303 (string-match "\\`\\*" (car stuff)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
304 (setq stuff (cons '* (cons (substring (car stuff) 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
305 (cdr stuff)))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
306 (setq calc-next-why (cons stuff calc-next-why))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
307 nil)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
308
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
309 ;; True if A is a constant or vector of constants. [P x] [Public]
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
310 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
311 (defun math-constp (a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
312 (or (Math-scalarp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
313 (and (memq (car a) '(sdev intv mod vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
314 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
315 (while (and (setq a (cdr a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
316 (or (Math-scalarp (car a)) ; optimization
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
317 (math-constp (car a)))))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
318 (null a)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
319
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
320
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
321 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
322 (defun calc-roll-down-stack (n &optional m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
323 (if (< n 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
324 (calc-roll-up-stack (- n) m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
325 (if (or (= n 0) (> n (calc-stack-size))) (setq n (calc-stack-size)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
326 (or m (setq m 1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
327 (and (> n 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
328 (< m n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
329 (if (and calc-any-selections
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
330 (not calc-use-selections))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
331 (calc-roll-down-with-selections n m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
332 (calc-pop-push-list n
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
333 (append (calc-top-list m 1)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
334 (calc-top-list (- n m) (1+ m))))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
335
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
336 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
337 (defun calc-roll-up-stack (n &optional m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
338 (if (< n 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
339 (calc-roll-down-stack (- n) m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
340 (if (or (= n 0) (> n (calc-stack-size))) (setq n (calc-stack-size)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
341 (or m (setq m 1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
342 (and (> n 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
343 (< m n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
344 (if (and calc-any-selections
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
345 (not calc-use-selections))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
346 (calc-roll-up-with-selections n m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
347 (calc-pop-push-list n
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
348 (append (calc-top-list (- n m) 1)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
349 (calc-top-list m (- n m -1))))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
350
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
351
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
352 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
353 (defun calc-do-refresh ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
354 (if calc-hyperbolic-flag
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
355 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
356 (setq calc-display-dirty t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
357 nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
358 (calc-refresh)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
359 t))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
360
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
361
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
362 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
363 (defun calc-record-list (vals &optional prefix)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
364 (while vals
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
365 (or (eq (car vals) 'top-of-stack)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
366 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
367 (calc-record (car vals) prefix)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
368 (setq prefix "...")))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
369 (setq vals (cdr vals))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
370
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
371
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
372 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
373 (defun calc-last-args-stub (arg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
374 (interactive "p")
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
375 (require 'calc-ext)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
376 (calc-last-args arg))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
377
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
378
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
379 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
380 (defun calc-power (arg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
381 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
382 (calc-slow-wrapper
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
383 (if (and (featurep 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
384 (calc-is-inverse))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
385 (calc-binary-op "root" 'calcFunc-nroot arg nil nil)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
386 (calc-binary-op "^" 'calcFunc-pow arg nil nil '^))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
387
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
388 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
389 (defun calc-mod (arg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
390 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
391 (calc-slow-wrapper
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
392 (calc-binary-op "%" 'calcFunc-mod arg nil nil '%)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
393
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
394 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
395 (defun calc-inv (arg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
396 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
397 (calc-slow-wrapper
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
398 (calc-unary-op "inv" 'calcFunc-inv arg)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
399
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
400 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
401 (defun calc-percent ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
402 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
403 (calc-slow-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
404 (calc-pop-push-record-list
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
405 1 "%" (list (list 'calcFunc-percent (calc-top-n 1))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
406
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
407
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
408 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
409 (defun calc-over (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
410 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
411 (if n
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
412 (calc-enter (- (prefix-numeric-value n)))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
413 (calc-enter -2)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
414
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
415
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
416 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
417 (defun calc-pop-above (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
418 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
419 (if n
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
420 (calc-pop (- (prefix-numeric-value n)))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
421 (calc-pop -2)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
422
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
423 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
424 (defun calc-roll-down (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
425 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
426 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
427 (let ((nn (prefix-numeric-value n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
428 (cond ((null n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
429 (calc-roll-down-stack 2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
430 ((> nn 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
431 (calc-roll-down-stack nn))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
432 ((= nn 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
433 (calc-pop-push-list (calc-stack-size)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
434 (reverse
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
435 (calc-top-list (calc-stack-size)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
436 (t
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
437 (calc-roll-down-stack (calc-stack-size) (- nn)))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
438
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
439 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
440 (defun calc-roll-up (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
441 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
442 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
443 (let ((nn (prefix-numeric-value n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
444 (cond ((null n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
445 (calc-roll-up-stack 3))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
446 ((> nn 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
447 (calc-roll-up-stack nn))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
448 ((= nn 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
449 (calc-pop-push-list (calc-stack-size)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
450 (reverse
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
451 (calc-top-list (calc-stack-size)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
452 (t
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
453 (calc-roll-up-stack (calc-stack-size) (- nn)))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
454
104099
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
455 ;;;###autoload
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
456 (defun calc-transpose-lines (&optional arg)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
457 "Transpose previous line and current line.
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
458 With argument ARG, move previous line past ARG lines.
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
459 With argument 0, switch line point is in with line mark is in."
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
460 (interactive "p")
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
461 (setq arg (or arg 1))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
462 (let (bot-line mid-line end-line
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
463 old-top-list new-top-list
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
464 bot-cell mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
465 prev-mid-cell post-mid-cell post-bot-cell)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
466 (calc-wrapper
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
467 (when (eq major-mode 'calc-mode)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
468 (cond
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
469 ;; exchange point and mark
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
470 ((= 0 arg)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
471 (setq bot-line (calc-locate-cursor-element (point))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
472 mid-line (mark))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
473 (if mid-line
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
474 (setq mid-line (calc-locate-cursor-element mid-line)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
475 end-line (1+ mid-line))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
476 (error "No mark set"))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
477 (if (< bot-line mid-line)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
478 (let ((temp mid-line))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
479 (setq mid-line bot-line
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
480 bot-line temp))))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
481 ;; move bot-line to mid-line that is above bot-line on stack (that is
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
482 ;; to say mid-line displayed below bot-line in *Calculator* buffer)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
483 ((> arg 0)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
484 (setq bot-line (1+ (calc-locate-cursor-element (point)))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
485 mid-line (- bot-line arg)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
486 end-line mid-line))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
487 ;; move bot-line to mid-line that is above bot-line on stack (that is
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
488 ;; to say mid-line displayed below bot-line in *Calculator* buffer)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
489 ((< arg 0)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
490 (setq mid-line (1+ (calc-locate-cursor-element (point)))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
491 bot-line (- mid-line arg)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
492 end-line bot-line)))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
493 (calc-check-stack bot-line)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
494 (if (= 0 mid-line)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
495 (error "Can't transpose beyond top"))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
496 (setq old-top-list (nreverse (calc-top-list bot-line)))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
497 ;; example: (arg = 2)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
498 ;; old-top-list =
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
499 ;; 1 <-- top of stack (bottom of *Calculator* buffer)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
500 ;; 2
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
501 ;; 3 <-- mid-line = 3
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
502 ;; 4 <-- point
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
503 ;; 5 <-- bot-line = 5
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
504 (dotimes (i mid-line)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
505 (setq mid-cell old-top-list
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
506 old-top-list (cdr old-top-list))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
507 (setcdr mid-cell new-top-list)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
508 (setq new-top-list mid-cell))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
509 ;; example follow-up:
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
510 ;; old-top-list =
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
511 ;; 4
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
512 ;; 5
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
513 ;; new-top-list =
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
514 ;; 3 <-- mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
515 ;; 2
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
516 ;; 1
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
517 (setq prev-mid-cell old-top-list)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
518 (dotimes (i (- bot-line mid-line))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
519 (setq bot-cell old-top-list
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
520 old-top-list (cdr old-top-list))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
521 (setcdr bot-cell new-top-list)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
522 (setq new-top-list bot-cell))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
523 (setq post-mid-cell (cdr mid-cell)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
524 post-bot-cell (cdr bot-cell))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
525 ;; example follow-up:
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
526 ;; new-top-list =
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
527 ;; 5 <-- bot-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
528 ;; 4 <-- prev-mid-cell & post-bot-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
529 ;; 3 <-- mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
530 ;; 2 <-- post-mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
531 ;; 1
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
532 (cond
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
533 ((= 0 arg); swap bot and mid
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
534 (setcdr mid-cell post-bot-cell)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
535 (setcdr bot-cell post-mid-cell)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
536 (setcdr prev-mid-cell bot-cell)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
537 ;; example follow-up:
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
538 ;; 3 <-- mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
539 ;; 4 <-- post-bot-cell & prev-mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
540 ;; 5 <-- bot-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
541 ;; 2 <-- post-mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
542 ;; 1
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
543 (setq new-top-list mid-cell))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
544 ((< 0 arg) ; move bot just after mid
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
545 (setcdr mid-cell bot-cell)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
546 (setcdr bot-cell post-mid-cell)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
547 ;; example follow-up:
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
548 ;; new-top-list =
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
549 ;; 4 <-- post-bot-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
550 ;; 3 <-- mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
551 ;; 5 <-- bot-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
552 ;; 2 <-- post-mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
553 ;; 1
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
554 (setq new-top-list post-bot-cell))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
555 ((> 0 arg) ; move mid just before bot
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
556 (setcdr mid-cell bot-cell)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
557 (setcdr prev-mid-cell post-mid-cell)
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
558 ;; example follow-up:
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
559 ;; new-top-list =
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
560 ;; 3 <-- mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
561 ;; 5 <-- bot-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
562 ;; 4 <-- prev-mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
563 ;; 2 <-- post-mid-cell
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
564 ;; 1
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
565 (setq new-top-list mid-cell)))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
566 (calc-pop-push-list bot-line new-top-list)))
e02e4e827099 (calc-transpose-lines): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 101001
diff changeset
567 (calc-cursor-stack-index (1- end-line))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
568
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
569
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
570
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
571 ;;; Other commands.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
572
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
573 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
574 (defun calc-num-prefix-name (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
575 (cond ((eq n '-) "- ")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
576 ((equal n '(4)) "C-u ")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
577 ((consp n) (format "%d " (car n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
578 ((integerp n) (format "%d " n))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
579 (t "")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
580
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
581 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
582 (defun calc-missing-key (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
583 "This is a placeholder for a command which needs to be loaded from calc-ext.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
584 When this key is used, calc-ext (the Calculator extensions module) will be
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
585 loaded and the keystroke automatically re-typed."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
586 (interactive "P")
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
587 (require 'calc-ext)
101001
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
588 (if (keymapp (key-binding (char-to-string last-command-event)))
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
589 (message "%s%c-" (calc-num-prefix-name n) last-command-event))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
590 (calc-unread-command)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
591 (setq prefix-arg n))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
592
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
593 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
594 (defun calc-shift-Y-prefix-help ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
595 (interactive)
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
596 (require 'calc-ext)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
597 (calc-do-prefix-help calc-Y-help-msgs "other" ?Y))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
598
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
599
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
600
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
601
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
602 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
603 (defun calcDigit-letter ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
604 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
605 (if (calc-minibuffer-contains "[-+]?\\(1[1-9]\\|[2-9][0-9]\\)#.*")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
606 (progn
101001
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
607 (setq last-command-event (upcase last-command-event))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
608 (calcDigit-key))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
609 (calcDigit-nondigit)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
610
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
611
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
612 ;; A Lisp version of temp_minibuffer_message from minibuf.c.
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
613 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
614 (defun calc-temp-minibuffer-message (m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
615 (let ((savemax (point-max)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
616 (save-excursion
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
617 (goto-char (point-max))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
618 (insert m))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
619 (let ((okay nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
620 (unwind-protect
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
621 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
622 (sit-for 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
623 (identity 1) ; this forces a call to QUIT; in bytecode.c.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
624 (setq okay t))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
625 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
626 (delete-region savemax (point-max))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
627 (or okay (abort-recursive-edit)))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
628
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
629
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
630 (put 'math-with-extra-prec 'lisp-indent-hook 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
631
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
632
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
633 ;; Concatenate two vectors, or a vector and an object. [V O O] [Public]
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
634 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
635 (defun math-concat (v1 v2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
636 (if (stringp v1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
637 (concat v1 v2)
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
638 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
639 (if (and (or (math-objvecp v1) (math-known-scalarp v1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
640 (or (math-objvecp v2) (math-known-scalarp v2)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
641 (append (if (and (math-vectorp v1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
642 (or (math-matrixp v1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
643 (not (math-matrixp v2))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
644 v1
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
645 (list 'vec v1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
646 (if (and (math-vectorp v2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
647 (or (math-matrixp v2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
648 (not (math-matrixp v1))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
649 (cdr v2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
650 (list v2)))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
651 (list '| v1 v2))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
652
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
653
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
654 ;; True if A is zero. Works for un-normalized values. [P n] [Public]
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
655 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
656 (defun math-zerop (a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
657 (if (consp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
658 (cond ((memq (car a) '(bigpos bigneg))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
659 (while (eq (car (setq a (cdr a))) 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
660 (null a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
661 ((memq (car a) '(frac float polar mod))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
662 (math-zerop (nth 1 a)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
663 ((eq (car a) 'cplx)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
664 (and (math-zerop (nth 1 a)) (math-zerop (nth 2 a))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
665 ((eq (car a) 'hms)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
666 (and (math-zerop (nth 1 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
667 (math-zerop (nth 2 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
668 (math-zerop (nth 3 a)))))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
669 (eq a 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
670
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
671
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
672 ;; True if A is real and negative. [P n] [Public]
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
673
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
674 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
675 (defun math-negp (a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
676 (if (consp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
677 (cond ((eq (car a) 'bigpos) nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
678 ((eq (car a) 'bigneg) (cdr a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
679 ((memq (car a) '(float frac))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
680 (Math-integer-negp (nth 1 a)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
681 ((eq (car a) 'hms)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
682 (if (math-zerop (nth 1 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
683 (if (math-zerop (nth 2 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
684 (math-negp (nth 3 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
685 (math-negp (nth 2 a)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
686 (math-negp (nth 1 a))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
687 ((eq (car a) 'date)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
688 (math-negp (nth 1 a)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
689 ((eq (car a) 'intv)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
690 (or (math-negp (nth 3 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
691 (and (math-zerop (nth 3 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
692 (memq (nth 1 a) '(0 2)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
693 ((equal a '(neg (var inf var-inf))) t))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
694 (< a 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
695
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
696 ;; True if A is a negative number or an expression the starts with '-'.
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
697 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
698 (defun math-looks-negp (a) ; [P x] [Public]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
699 (or (Math-negp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
700 (eq (car-safe a) 'neg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
701 (and (memq (car-safe a) '(* /))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
702 (or (math-looks-negp (nth 1 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
703 (math-looks-negp (nth 2 a))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
704 (and (eq (car-safe a) '-)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
705 (math-looks-negp (nth 1 a)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
706
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
707
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
708 ;; True if A is real and positive. [P n] [Public]
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
709 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
710 (defun math-posp (a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
711 (if (consp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
712 (cond ((eq (car a) 'bigpos) (cdr a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
713 ((eq (car a) 'bigneg) nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
714 ((memq (car a) '(float frac))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
715 (Math-integer-posp (nth 1 a)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
716 ((eq (car a) 'hms)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
717 (if (math-zerop (nth 1 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
718 (if (math-zerop (nth 2 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
719 (math-posp (nth 3 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
720 (math-posp (nth 2 a)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
721 (math-posp (nth 1 a))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
722 ((eq (car a) 'date)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
723 (math-posp (nth 1 a)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
724 ((eq (car a) 'mod)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
725 (not (math-zerop (nth 1 a))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
726 ((eq (car a) 'intv)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
727 (or (math-posp (nth 2 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
728 (and (math-zerop (nth 2 a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
729 (memq (nth 1 a) '(0 1)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
730 ((equal a '(var inf var-inf)) t))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
731 (> a 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
732
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
733 ;;;###autoload
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
734 (defalias 'math-fixnump 'integerp)
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
735 ;;;###autoload
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
736 (defalias 'math-fixnatnump 'natnump)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
737
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
738
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
739 ;; True if A is an even integer. [P R R] [Public]
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
740 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
741 (defun math-evenp (a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
742 (if (consp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
743 (and (memq (car a) '(bigpos bigneg))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
744 (= (% (nth 1 a) 2) 0))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
745 (= (% a 2) 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
746
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
747 ;; Compute A / 2, for small or big integer A. [I i]
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
748 ;; If A is negative, type of truncation is undefined.
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
749 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
750 (defun math-div2 (a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
751 (if (consp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
752 (if (cdr a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
753 (math-normalize (cons (car a) (math-div2-bignum (cdr a))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
754 0)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
755 (/ a 2)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
756
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
757 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
758 (defun math-div2-bignum (a) ; [l l]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
759 (if (cdr a)
81596
d175ac539ca9 (math-div2-bignum): Use math-bignum-digit-size.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 77465
diff changeset
760 (cons (+ (/ (car a) 2) (* (% (nth 1 a) 2) (/ math-bignum-digit-size 2)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
761 (math-div2-bignum (cdr a)))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
762 (list (/ (car a) 2))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
763
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
764
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
765 ;; Reject an argument to a calculator function. [Public]
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
766 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
767 (defun math-reject-arg (&optional a p option)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
768 (if option
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
769 (calc-record-why option p a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
770 (if p
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
771 (calc-record-why p a)))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
772 (signal 'wrong-type-argument (and a (if p (list p a) (list a)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
773
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
774
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
775 ;; Coerce A to be an integer (by truncation toward zero). [I N] [Public]
58480
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
776
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
777 ;; The variable math-trunc-prec is local to math-trunc, but used by
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
778 ;; math-trunc-fancy in calc-arith.el, which is called by math-trunc.
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
779
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
780 ;;;###autoload
58480
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
781 (defun math-trunc (a &optional math-trunc-prec)
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
782 (cond (math-trunc-prec
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
783 (require 'calc-ext)
58480
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
784 (math-trunc-special a math-trunc-prec))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
785 ((Math-integerp a) a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
786 ((Math-looks-negp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
787 (math-neg (math-trunc (math-neg a))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
788 ((eq (car a) 'float)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
789 (math-scale-int (nth 1 a) (nth 2 a)))
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
790 (t (require 'calc-ext)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
791 (math-trunc-fancy a))))
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
792 ;;;###autoload
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
793 (defalias 'calcFunc-trunc 'math-trunc)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
794
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
795 ;; Coerce A to be an integer (by truncation toward minus infinity). [I N]
58480
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
796
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
797 ;; The variable math-floor-prec is local to math-floor, but used by
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
798 ;; math-floor-fancy in calc-arith.el, which is called by math-floor.
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
799
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
800 ;;;###autoload
58480
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
801 (defun math-floor (a &optional math-floor-prec) ; [Public]
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
802 (cond (math-floor-prec
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
803 (require 'calc-ext)
58480
d11199c971ec (math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57711
diff changeset
804 (math-floor-special a math-floor-prec))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
805 ((Math-integerp a) a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
806 ((Math-messy-integerp a) (math-trunc a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
807 ((Math-realp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
808 (if (Math-negp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
809 (math-add (math-trunc a) -1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
810 (math-trunc a)))
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
811 (t (require 'calc-ext)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
812 (math-floor-fancy a))))
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
813 ;;;###autoload
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
814 (defalias 'calcFunc-floor 'math-floor)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
815
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
816
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
817 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
818 (defun math-imod (a b) ; [I I I] [Public]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
819 (if (and (not (consp a)) (not (consp b)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
820 (if (= b 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
821 (math-reject-arg a "*Division by zero")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
822 (% a b))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
823 (cdr (math-idivmod a b))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
824
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
825
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
826 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
827 (defun calcFunc-inv (m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
828 (if (Math-vectorp m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
829 (progn
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
830 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
831 (if (math-square-matrixp m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
832 (or (math-with-extra-prec 2 (math-matrix-inv-raw m))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
833 (math-reject-arg m "*Singular matrix"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
834 (math-reject-arg m 'square-matrixp)))
66480
feb65aa82eeb (calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 64325
diff changeset
835 (if (and
feb65aa82eeb (calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 64325
diff changeset
836 (require 'calc-arith)
feb65aa82eeb (calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 64325
diff changeset
837 (math-known-matrixp m))
feb65aa82eeb (calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 64325
diff changeset
838 (math-pow m -1)
feb65aa82eeb (calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 64325
diff changeset
839 (math-div 1 m))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
840
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
841 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
842 (defun math-do-working (msg arg)
40998
ee9c2872370b Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents: 40785
diff changeset
843 (or executing-kbd-macro
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
844 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
845 (calc-set-command-flag 'clear-message)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
846 (if math-working-step
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
847 (if math-working-step-2
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
848 (setq msg (format "[%d/%d] %s"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
849 math-working-step math-working-step-2 msg))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
850 (setq msg (format "[%d] %s" math-working-step msg))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
851 (message "Working... %s = %s" msg
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
852 (math-showing-full-precision (math-format-number arg))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
853
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
854
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
855 ;; Compute A modulo B, defined in terms of truncation toward minus infinity.
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
856 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
857 (defun math-mod (a b) ; [R R R] [Public]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
858 (cond ((and (Math-zerop a) (not (eq (car-safe a) 'mod))) a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
859 ((Math-zerop b)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
860 (math-reject-arg a "*Division by zero"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
861 ((and (Math-natnump a) (Math-natnump b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
862 (math-imod a b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
863 ((and (Math-anglep a) (Math-anglep b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
864 (math-sub a (math-mul (math-floor (math-div a b)) b)))
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
865 (t (require 'calc-ext)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
866 (math-mod-fancy a b))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
867
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
868
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
869
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
870 ;;; General exponentiation.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
871
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
872 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
873 (defun math-pow (a b) ; [O O N] [Public]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
874 (cond ((equal b '(var nan var-nan))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
875 b)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
876 ((Math-zerop a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
877 (if (and (Math-scalarp b) (Math-posp b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
878 (if (math-floatp b) (math-float a) a)
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
879 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
880 (math-pow-of-zero a b)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
881 ((or (eq a 1) (eq b 1)) a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
882 ((or (equal a '(float 1 0)) (equal b '(float 1 0))) a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
883 ((Math-zerop b)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
884 (if (Math-scalarp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
885 (if (or (math-floatp a) (math-floatp b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
886 '(float 1 0) 1)
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
887 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
888 (math-pow-zero a b)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
889 ((and (Math-integerp b) (or (Math-numberp a) (Math-vectorp a)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
890 (if (and (equal a '(float 1 1)) (integerp b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
891 (math-make-float 1 b)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
892 (math-with-extra-prec 2
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
893 (math-ipow a b))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
894 (t
58613
3eb7a394510d (calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58543
diff changeset
895 (require 'calc-ext)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
896 (math-pow-fancy a b))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
897
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
898 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
899 (defun math-ipow (a n) ; [O O I] [Public]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
900 (cond ((Math-integer-negp n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
901 (math-ipow (math-div 1 a) (Math-integer-neg n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
902 ((not (consp n))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
903 (if (and (Math-ratp a) (> n 20))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
904 (math-iipow-show a n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
905 (math-iipow a n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
906 ((math-evenp n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
907 (math-ipow (math-mul a a) (math-div2 n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
908 (t
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
909 (math-mul a (math-ipow (math-mul a a)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
910 (math-div2 (math-add n -1)))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
911
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
912 (defun math-iipow (a n) ; [O O S]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
913 (cond ((= n 0) 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
914 ((= n 1) a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
915 ((= (% n 2) 0) (math-iipow (math-mul a a) (/ n 2)))
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
916 (t (math-mul a (math-iipow (math-mul a a) (/ n 2))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
917
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
918 (defun math-iipow-show (a n) ; [O O S]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
919 (math-working "pow" a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
920 (let ((val (cond
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
921 ((= n 0) 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
922 ((= n 1) a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
923 ((= (% n 2) 0) (math-iipow-show (math-mul a a) (/ n 2)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
924 (t (math-mul a (math-iipow-show (math-mul a a) (/ n 2)))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
925 (math-working "pow" val)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
926 val))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
927
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
928
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
929 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
930 (defun math-read-radix-digit (dig) ; [D S; Z S]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
931 (if (> dig ?9)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
932 (if (< dig ?A)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
933 nil
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
934 (- dig 55))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
935 (if (>= dig ?0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
936 (- dig ?0)
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
937 nil)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
938
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
939
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
940 ;;; Bug reporting
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
941
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
942 ;;;###autoload
41377
be3e9c2f0159 (report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents: 41363
diff changeset
943 (defun report-calc-bug ()
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
944 "Report a bug in Calc, the GNU Emacs calculator.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
945 Prompts for bug subject. Leaves you in a mail buffer."
41377
be3e9c2f0159 (report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents: 41363
diff changeset
946 (interactive)
be3e9c2f0159 (report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents: 41363
diff changeset
947 (let ((reporter-prompt-for-summary-p t))
97463
c28e1ae0ccfa (report-calc-bug): Remove version number.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 94654
diff changeset
948 (reporter-submit-bug-report calc-bug-address "Calc"
c28e1ae0ccfa (report-calc-bug): Remove version number.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 94654
diff changeset
949 nil nil nil
41377
be3e9c2f0159 (report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents: 41363
diff changeset
950 "Please describe exactly what actions triggered the bug and the
41363
f17cae9ea728 (report-calc-bug): Use reporter.el.
Colin Walters <walters@gnu.org>
parents: 41359
diff changeset
951 precise symptoms of the bug. If possible, include a backtrace by
f17cae9ea728 (report-calc-bug): Use reporter.el.
Colin Walters <walters@gnu.org>
parents: 41359
diff changeset
952 doing 'M-x toggle-debug-on-error', then reproducing the bug.
41377
be3e9c2f0159 (report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents: 41363
diff changeset
953 " )))
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
954 ;;;###autoload
41267
e9718841a5b1 (math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents: 41045
diff changeset
955 (defalias 'calc-report-bug 'report-calc-bug)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
956
58664
f23c98cc77a1 Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58613
diff changeset
957 (provide 'calc-misc)
f23c98cc77a1 Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58613
diff changeset
958
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
959 ;; Local variables:
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
960 ;; generated-autoload-file: "calc-loaddefs.el"
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
961 ;; End:
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
962
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
963 ;; arch-tag: 7984d9d0-62e5-41dc-afb8-e904b975f250
41045
3491bfbd825e (math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents: 40998
diff changeset
964 ;;; calc-misc.el ends here