Mercurial > emacs
changeset 41264:0759b2de09c1
(calc-over-notation): Use `completing-read'.
Change all toplevel `setq' forms to `defvar' forms, and move them
before their first use. Use `when', `unless'. Remove trailing
periods from error forms. Add description and headers suggested by
Emacs Lisp coding conventions.
author | Colin Walters <walters@gnu.org> |
---|---|
date | Mon, 19 Nov 2001 07:34:00 +0000 |
parents | 6decaeb7d760 |
children | eb26445485bc |
files | lisp/calc/calc-frac.el lisp/calc/calc-funcs.el |
diffstat | 2 files changed, 41 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/calc/calc-frac.el Mon Nov 19 06:46:41 2001 +0000 +++ b/lisp/calc/calc-frac.el Mon Nov 19 07:34:00 2001 +0000 @@ -1,8 +1,9 @@ -;; Calculator for GNU Emacs, part II [calc-frac.el] +;;; calc-frac.el --- fraction functions for Calc + ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. -;; Written by Dave Gillespie, daveg@synaptics.com. -;; This file is part of GNU Emacs. +;; Author: David Gillespie <daveg@synaptics.com> +;; Maintainer: Colin Walters <walters@debian.org> ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY. No author or distributor @@ -19,7 +20,9 @@ ;; file named COPYING. Among other things, the copyright notice ;; and this notice must be preserved on all copies. +;;; Commentary: +;;; Code: ;; This file is autoloaded from calc-ext.el. (require 'calc-ext) @@ -28,7 +31,6 @@ (defun calc-Need-calc-frac () nil) - (defun calc-fdiv (arg) (interactive "P") (calc-slow-wrapper @@ -49,7 +51,12 @@ (defun calc-over-notation (fmt) - (interactive "sFraction separator (:, ::, /, //, :/): ") + (interactive + (list + (completing-read "Fraction separator: " (mapcar (lambda (s) + (cons s 0)) + '(":" "::" "/" "//" ":/")) + nil t))) (calc-wrapper (if (string-match "\\`\\([^ 0-9][^ 0-9]?\\)[0-9]*\\'" fmt) (let ((n nil)) @@ -58,7 +65,7 @@ fmt (math-match-substring fmt 1))) (if (eq n 0) (error "Bad denominator")) (calc-change-mode 'calc-frac-format (list fmt n) t)) - (error "Bad fraction separator format.")))) + (error "Bad fraction separator format")))) (defun calc-slash-notation (n) (interactive "P") @@ -71,11 +78,8 @@ (calc-wrapper (calc-change-mode 'calc-prefer-frac n nil t) (message (if calc-prefer-frac - "Integer division will now generate fractions." - "Integer division will now generate floating-point results.")))) - - - + "Integer division will now generate fractions" + "Integer division will now generate floating-point results")))) ;;;; Fractions. @@ -130,8 +134,6 @@ (nth 1 b)))) - - ;;; Convert a real value to fractional form. [T R I; T R F] [Public] (defun calcFunc-frac (a &optional tol) (or tol (setq tol 0))
--- a/lisp/calc/calc-funcs.el Mon Nov 19 06:46:41 2001 +0000 +++ b/lisp/calc/calc-funcs.el Mon Nov 19 07:34:00 2001 +0000 @@ -1,6 +1,9 @@ -;; Calculator for GNU Emacs, part II [calc-funcs.el] +;;; calc-funcs.el --- well-known functions for Calc + ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. -;; Written by Dave Gillespie, daveg@synaptics.com. + +;; Author: David Gillespie <daveg@synaptics.com> +;; Maintainer: Colin Walters <walters@debian.org> ;; This file is part of GNU Emacs. @@ -19,7 +22,9 @@ ;; file named COPYING. Among other things, the copyright notice ;; and this notice must be preserved on all copies. +;;; Commentary: +;;; Code: ;; This file is autoloaded from calc-ext.el. (require 'calc-ext) @@ -198,6 +203,7 @@ ;;; Incomplete gamma function. +(defvar math-current-gamma-value nil) (defun calcFunc-gammaP (a x) (if (equal x '(var inf var-inf)) '(float 1 0) @@ -248,7 +254,6 @@ (math-inc-gamma-series a x) (math-sub (or math-current-gamma-value (calcFunc-gamma a)) (math-inc-gamma-cfrac a x)))))) -(setq math-current-gamma-value nil) (defun calcFunc-gammaG (a x) (if (equal x '(var inf var-inf)) @@ -371,6 +376,7 @@ ;;; Incomplete beta function. +(defvar math-current-beta-value nil) (defun calcFunc-betaI (x a b) (cond ((math-zerop x) '(float 0 0)) @@ -445,7 +451,6 @@ (math-div (math-mul bt (math-beta-cfrac b a (math-sub 1 x))) b)))))))) -(setq math-current-beta-value nil) (defun math-beta-cfrac (a b x) (let ((qab (math-add a b)) @@ -796,6 +801,23 @@ (calcFunc-euler n '(float 5 -1))) (calcFunc-euler n '(frac 1 2)))))) +(defvar math-bernoulli-b-cache '((frac -174611 + (bigpos 0 200 291 698 662 857 802)) + (frac 43867 (bigpos 0 944 170 217 94 109 5)) + (frac -3617 (bigpos 0 880 842 622 670 10)) + (frac 1 (bigpos 600 249 724 74)) + (frac -691 (bigpos 0 368 674 307 1)) + (frac 1 (bigpos 160 900 47)) + (frac -1 (bigpos 600 209 1)) + (frac 1 30240) (frac -1 720) + (frac 1 12) 1 )) + +(defvar math-bernoulli-B-cache '((frac -174611 330) (frac 43867 798) + (frac -3617 510) (frac 7 6) (frac -691 2730) + (frac 5 66) (frac -1 30) (frac 1 42) + (frac -1 30) (frac 1 6) 1 )) + +(defvar math-bernoulli-cache-size 11) (defun math-bernoulli-coefs (n) (let* ((coefs (list (calcFunc-bern n))) (nn (math-trunc n)) @@ -844,25 +866,6 @@ ;;; A faster method would be to use "tangent numbers", c.f., Concrete ;;; Mathematics pg. 273. -(setq math-bernoulli-b-cache '( (frac -174611 - (bigpos 0 200 291 698 662 857 802)) - (frac 43867 (bigpos 0 944 170 217 94 109 5)) - (frac -3617 (bigpos 0 880 842 622 670 10)) - (frac 1 (bigpos 600 249 724 74)) - (frac -691 (bigpos 0 368 674 307 1)) - (frac 1 (bigpos 160 900 47)) - (frac -1 (bigpos 600 209 1)) - (frac 1 30240) (frac -1 720) - (frac 1 12) 1 )) - -(setq math-bernoulli-B-cache '( (frac -174611 330) (frac 43867 798) - (frac -3617 510) (frac 7 6) (frac -691 2730) - (frac 5 66) (frac -1 30) (frac 1 42) - (frac -1 30) (frac 1 6) 1 )) - -(setq math-bernoulli-cache-size 11) - - ;;; Probability distributions.