summaryrefslogtreecommitdiff
path: root/lisp/calc/calc.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2009-08-30 05:12:46 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2009-08-30 05:12:46 +0000
commit5cb16bfc75cea38804da7b21b53a9cd4eec14f63 (patch)
treedae225a67c39e70b626974fc9396e10c1dfb6ec4 /lisp/calc/calc.el
parent0aeb71a7e277bcf766f1c45bb0d26d6115482d9d (diff)
downloademacs-5cb16bfc75cea38804da7b21b53a9cd4eec14f63.tar.gz
Improve commenting convention.
(calc-digit-map, toplevel): Simplify.
Diffstat (limited to 'lisp/calc/calc.el')
-rw-r--r--lisp/calc/calc.el236
1 files changed, 111 insertions, 125 deletions
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index 790647d62ca..d38d6b7dbde 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -1043,25 +1043,13 @@ Used by `calc-user-invocation'.")
map)
"The key map for Calc.")
-
-
(defvar calc-digit-map
(let ((map (make-keymap)))
- (if (featurep 'xemacs)
- (map-keymap (function
- (lambda (keys bind)
- (define-key map keys
- (if (eq bind 'undefined)
- 'undefined 'calcDigit-nondigit))))
- calc-mode-map)
- (let ((cmap (nth 1 calc-mode-map))
- (dmap (nth 1 map))
- (i 0))
- (while (< i 128)
- (aset dmap i
- (if (eq (aref cmap i) 'undefined)
- 'undefined 'calcDigit-nondigit))
- (setq i (1+ i)))))
+ (map-keymap (lambda (key bind)
+ (define-key map (vector key)
+ (if (eq bind 'undefined)
+ 'undefined 'calcDigit-nondigit)))
+ calc-mode-map)
(mapc (lambda (x) (define-key map (char-to-string x) 'calcDigit-key))
"_0123456789.e+-:n#@oh'\"mspM")
(mapc (lambda (x) (define-key map (char-to-string x) 'calcDigit-letter))
@@ -1078,15 +1066,13 @@ Used by `calc-user-invocation'.")
(define-key calc-digit-map x 'calcDigit-backspace)
(define-key calc-mode-map x 'calc-pop)
(define-key calc-mode-map
- (if (vectorp x)
- (if (featurep 'xemacs)
- (if (= (length x) 1)
- (vector (if (consp (aref x 0))
- (cons 'meta (aref x 0))
- (list 'meta (aref x 0))))
- "\e\C-d")
- (vconcat "\e" x))
- (concat "\e" x))
+ (if (and (vectorp x) (featurep 'xemacs))
+ (if (= (length x) 1)
+ (vector (if (consp (aref x 0))
+ (cons 'meta (aref x 0))
+ (list 'meta (aref x 0))))
+ "\e\C-d")
+ (vconcat "\e" x))
'calc-pop-above))
(error nil)))
(if calc-scan-for-dels
@@ -2436,101 +2422,101 @@ largest Emacs integer.")
;;;; Arithmetic routines.
-;;;
-;;; An object as manipulated by one of these routines may take any of the
-;;; following forms:
-;;;
-;;; integer An integer. For normalized numbers, this format
-;;; is used only for
-;;; negative math-small-integer-size + 1 to
-;;; math-small-integer-size - 1
-;;;
-;;; (bigpos N0 N1 N2 ...) A big positive integer,
-;;; N0 + N1*math-bignum-digit-size
-;;; + N2*(math-bignum-digit-size)^2 ...
-;;; (bigneg N0 N1 N2 ...) A big negative integer,
-;;; - N0 - N1*math-bignum-digit-size ...
-;;; Each digit N is in the range
-;;; 0 ... math-bignum-digit-size -1.
-;;; Normalized, always at least three N present,
-;;; and the most significant N is nonzero.
-;;;
-;;; (frac NUM DEN) A fraction. NUM and DEN are small or big integers.
-;;; Normalized, DEN > 1.
-;;;
-;;; (float NUM EXP) A floating-point number, NUM * 10^EXP;
-;;; NUM is a small or big integer, EXP is a small int.
-;;; Normalized, NUM is not a multiple of 10, and
-;;; abs(NUM) < 10^calc-internal-prec.
-;;; Normalized zero is stored as (float 0 0).
-;;;
-;;; (cplx REAL IMAG) A complex number; REAL and IMAG are any of above.
-;;; Normalized, IMAG is nonzero.
-;;;
-;;; (polar R THETA) Polar complex number. Normalized, R > 0 and THETA
-;;; is neither zero nor 180 degrees (pi radians).
-;;;
-;;; (vec A B C ...) Vector of objects A, B, C, ... A matrix is a
-;;; vector of vectors.
-;;;
-;;; (hms H M S) Angle in hours-minutes-seconds form. All three
-;;; components have the same sign; H and M must be
-;;; numerically integers; M and S are expected to
-;;; lie in the range [0,60).
-;;;
-;;; (date N) A date or date/time object. N is an integer to
-;;; store a date only, or a fraction or float to
-;;; store a date and time.
-;;;
-;;; (sdev X SIGMA) Error form, X +/- SIGMA. When normalized,
-;;; SIGMA > 0. X is any complex number and SIGMA
-;;; is real numbers; or these may be symbolic
-;;; expressions where SIGMA is assumed real.
-;;;
-;;; (intv MASK LO HI) Interval form. MASK is 0=(), 1=(], 2=[), or 3=[].
-;;; LO and HI are any real numbers, or symbolic
-;;; expressions which are assumed real, and LO < HI.
-;;; For [LO..HI], if LO = HI normalization produces LO,
-;;; and if LO > HI normalization produces [LO..LO).
-;;; For other intervals, if LO > HI normalization
-;;; sets HI equal to LO.
-;;;
-;;; (mod N M) Number modulo M. When normalized, 0 <= N < M.
-;;; N and M are real numbers.
-;;;
-;;; (var V S) Symbolic variable. V is a Lisp symbol which
-;;; represents the variable's visible name. S is
-;;; the symbol which actually stores the variable's
-;;; value: (var pi var-pi).
-;;;
-;;; In general, combining rational numbers in a calculation always produces
-;;; a rational result, but if either argument is a float, result is a float.
-
-;;; In the following comments, [x y z] means result is x, args must be y, z,
-;;; respectively, where the code letters are:
-;;;
-;;; O Normalized object (vector or number)
-;;; V Normalized vector
-;;; N Normalized number of any type
-;;; N Normalized complex number
-;;; R Normalized real number (float or rational)
-;;; F Normalized floating-point number
-;;; T Normalized rational number
-;;; I Normalized integer
-;;; B Normalized big integer
-;;; S Normalized small integer
-;;; D Digit (small integer, 0..999)
-;;; L Normalized bignum digit list (without "bigpos" or "bigneg" symbol)
-;;; or normalized vector element list (without "vec")
-;;; P Predicate (truth value)
-;;; X Any Lisp object
-;;; Z "nil"
-;;;
-;;; Lower-case letters signify possibly un-normalized values.
-;;; "L.D" means a cons of an L and a D.
-;;; [N N; n n] means result will be normalized if argument is.
-;;; Also, [Public] marks routines intended to be called from outside.
-;;; [This notation has been neglected in many recent routines.]
+;;
+;; An object as manipulated by one of these routines may take any of the
+;; following forms:
+;;
+;; integer An integer. For normalized numbers, this format
+;; is used only for
+;; negative math-small-integer-size + 1 to
+;; math-small-integer-size - 1
+;;
+;; (bigpos N0 N1 N2 ...) A big positive integer,
+;; N0 + N1*math-bignum-digit-size
+;; + N2*(math-bignum-digit-size)^2 ...
+;; (bigneg N0 N1 N2 ...) A big negative integer,
+;; - N0 - N1*math-bignum-digit-size ...
+;; Each digit N is in the range
+;; 0 ... math-bignum-digit-size -1.
+;; Normalized, always at least three N present,
+;; and the most significant N is nonzero.
+;;
+;; (frac NUM DEN) A fraction. NUM and DEN are small or big integers.
+;; Normalized, DEN > 1.
+;;
+;; (float NUM EXP) A floating-point number, NUM * 10^EXP;
+;; NUM is a small or big integer, EXP is a small int.
+;; Normalized, NUM is not a multiple of 10, and
+;; abs(NUM) < 10^calc-internal-prec.
+;; Normalized zero is stored as (float 0 0).
+;;
+;; (cplx REAL IMAG) A complex number; REAL and IMAG are any of above.
+;; Normalized, IMAG is nonzero.
+;;
+;; (polar R THETA) Polar complex number. Normalized, R > 0 and THETA
+;; is neither zero nor 180 degrees (pi radians).
+;;
+;; (vec A B C ...) Vector of objects A, B, C, ... A matrix is a
+;; vector of vectors.
+;;
+;; (hms H M S) Angle in hours-minutes-seconds form. All three
+;; components have the same sign; H and M must be
+;; numerically integers; M and S are expected to
+;; lie in the range [0,60).
+;;
+;; (date N) A date or date/time object. N is an integer to
+;; store a date only, or a fraction or float to
+;; store a date and time.
+;;
+;; (sdev X SIGMA) Error form, X +/- SIGMA. When normalized,
+;; SIGMA > 0. X is any complex number and SIGMA
+;; is real numbers; or these may be symbolic
+;; expressions where SIGMA is assumed real.
+;;
+;; (intv MASK LO HI) Interval form. MASK is 0=(), 1=(], 2=[), or 3=[].
+;; LO and HI are any real numbers, or symbolic
+;; expressions which are assumed real, and LO < HI.
+;; For [LO..HI], if LO = HI normalization produces LO,
+;; and if LO > HI normalization produces [LO..LO).
+;; For other intervals, if LO > HI normalization
+;; sets HI equal to LO.
+;;
+;; (mod N M) Number modulo M. When normalized, 0 <= N < M.
+;; N and M are real numbers.
+;;
+;; (var V S) Symbolic variable. V is a Lisp symbol which
+;; represents the variable's visible name. S is
+;; the symbol which actually stores the variable's
+;; value: (var pi var-pi).
+;;
+;; In general, combining rational numbers in a calculation always produces
+;; a rational result, but if either argument is a float, result is a float.
+
+;; In the following comments, [x y z] means result is x, args must be y, z,
+;; respectively, where the code letters are:
+;;
+;; O Normalized object (vector or number)
+;; V Normalized vector
+;; N Normalized number of any type
+;; N Normalized complex number
+;; R Normalized real number (float or rational)
+;; F Normalized floating-point number
+;; T Normalized rational number
+;; I Normalized integer
+;; B Normalized big integer
+;; S Normalized small integer
+;; D Digit (small integer, 0..999)
+;; L Normalized bignum digit list (without "bigpos" or "bigneg" symbol)
+;; or normalized vector element list (without "vec")
+;; P Predicate (truth value)
+;; X Any Lisp object
+;; Z "nil"
+;;
+;; Lower-case letters signify possibly un-normalized values.
+;; "L.D" means a cons of an L and a D.
+;; [N N; n n] means result will be normalized if argument is.
+;; Also, [Public] marks routines intended to be called from outside.
+;; [This notation has been neglected in many recent routines.]
(defvar math-eval-rules-cache)
(defvar math-eval-rules-cache-other)
@@ -2662,7 +2648,7 @@ largest Emacs integer.")
-;;; True if A is a floating-point real or complex number. [P x] [Public]
+;; True if A is a floating-point real or complex number. [P x] [Public]
(defun math-floatp (a)
(cond ((eq (car-safe a) 'float) t)
((memq (car-safe a) '(cplx polar mod sdev intv))
@@ -2674,7 +2660,7 @@ largest Emacs integer.")
-;;; Verify that A is a complete object and return A. [x x] [Public]
+;; Verify that A is a complete object and return A. [x x] [Public]
(defun math-check-complete (a)
(cond ((integerp a) a)
((eq (car-safe a) 'incomplete)
@@ -2684,7 +2670,7 @@ largest Emacs integer.")
-;;; Coerce integer A to be a bignum. [B S]
+;; Coerce integer A to be a bignum. [B S]
(defun math-bignum (a)
(if (>= a 0)
(cons 'bigpos (math-bignum-big a))
@@ -2697,7 +2683,7 @@ largest Emacs integer.")
(math-bignum-big (/ a math-bignum-digit-size)))))
-;;; Build a normalized floating-point number. [F I S]
+;; Build a normalized floating-point number. [F I S]
(defun math-make-float (mant exp)
(if (eq mant 0)
'(float 0 0)