Mercurial > emacs
comparison lisp/calc/calc-stuff.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 0d8b17d428b5 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; calc-stuff.el --- miscellaneous functions for Calc | 1 ;;; calc-stuff.el --- miscellaneous functions for Calc |
2 | 2 |
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, |
4 ;; 2005 Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: David Gillespie <daveg@synaptics.com> | 6 ;; Author: David Gillespie <daveg@synaptics.com> |
6 ;; Maintainers: D. Goel <deego@gnufans.org> | 7 ;; Maintainer: Jay Belanger <belanger@truman.edu> |
7 ;; Colin Walters <walters@debian.org> | |
8 | 8 |
9 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
10 | 10 |
11 ;; GNU Emacs is distributed in the hope that it will be useful, | 11 ;; GNU Emacs is distributed in the hope that it will be useful, |
12 ;; but WITHOUT ANY WARRANTY. No author or distributor | 12 ;; but WITHOUT ANY WARRANTY. No author or distributor |
26 ;;; Commentary: | 26 ;;; Commentary: |
27 | 27 |
28 ;;; Code: | 28 ;;; Code: |
29 | 29 |
30 ;; This file is autoloaded from calc-ext.el. | 30 ;; This file is autoloaded from calc-ext.el. |
31 | |
31 (require 'calc-ext) | 32 (require 'calc-ext) |
32 | |
33 (require 'calc-macs) | 33 (require 'calc-macs) |
34 | |
35 (defun calc-Need-calc-stuff () nil) | |
36 | |
37 | 34 |
38 (defun calc-num-prefix (n) | 35 (defun calc-num-prefix (n) |
39 "Use the number at the top of stack as the numeric prefix for the next command. | 36 "Use the number at the top of stack as the numeric prefix for the next command. |
40 With a prefix, push that prefix as a number onto the stack." | 37 With a prefix, push that prefix as a number onto the stack." |
41 (interactive "P") | 38 (interactive "P") |
163 | 160 |
164 (defun calc-version () | 161 (defun calc-version () |
165 (interactive) | 162 (interactive) |
166 (message "Calc %s" calc-version)) | 163 (message "Calc %s" calc-version)) |
167 | 164 |
165 ;; The following caches are declared in other files, but are | |
166 ;; reset here. | |
167 (defvar math-lud-cache) ; calc-mtx.el | |
168 (defvar math-log2-cache) ; calc-bin.el | |
169 (defvar math-radix-digits-cache) ; calc-bin.el | |
170 (defvar math-radix-float-cache-tag) ; calc-bin.el | |
171 (defvar math-random-cache) ; calc-comb.el | |
172 (defvar math-max-digits-cache) ; calc-bin.el | |
173 (defvar math-integral-cache) ; calcalg2.el | |
174 (defvar math-units-table) ; calc-units.el | |
175 (defvar math-decls-cache-tag) ; calc-arith.el | |
176 (defvar math-format-date-cache) ; calc-forms.el | |
177 (defvar math-holidays-cache-tag) ; calc-forms.el | |
168 | 178 |
169 (defun calc-flush-caches (&optional inhibit-msg) | 179 (defun calc-flush-caches (&optional inhibit-msg) |
170 (interactive "P") | 180 (interactive "P") |
171 (calc-wrapper | 181 (calc-wrapper |
172 (setq math-lud-cache nil | 182 (setq math-lud-cache nil |
173 math-log2-cache nil | 183 math-log2-cache nil |
174 math-radix-digits-cache nil | 184 math-radix-digits-cache nil |
175 math-radix-float-cache-tag nil | 185 math-radix-float-cache-tag nil |
176 math-random-cache nil | 186 math-random-cache nil |
177 math-max-digits-cache nil | 187 math-max-digits-cache nil |
178 math-checked-rewrites nil | |
179 math-integral-cache nil | 188 math-integral-cache nil |
180 math-units-table nil | 189 math-units-table nil |
181 math-decls-cache-tag nil | 190 math-decls-cache-tag nil |
182 math-eval-rules-cache-tag t | 191 math-eval-rules-cache-tag t |
183 math-graph-var-cache nil | |
184 math-graph-data-cache nil | |
185 math-format-date-cache nil | 192 math-format-date-cache nil |
186 math-holidays-cache-tag t) | 193 math-holidays-cache-tag t) |
187 (mapcar (function (lambda (x) (set x -100))) math-cache-list) | 194 (mapcar (function (lambda (x) (set x -100))) math-cache-list) |
188 (unless inhibit-msg | 195 (unless inhibit-msg |
189 (message "All internal calculator caches have been reset")))) | 196 (message "All internal calculator caches have been reset")))) |
268 | 275 |
269 (defun calcFunc-pfrac (a &optional tol) | 276 (defun calcFunc-pfrac (a &optional tol) |
270 (math-map-over-constants (function (lambda (x) (calcFunc-frac x tol))) | 277 (math-map-over-constants (function (lambda (x) (calcFunc-frac x tol))) |
271 a)) | 278 a)) |
272 | 279 |
273 (defun math-map-over-constants (func expr) | 280 ;; The variable math-moc-func is local to math-map-over-constants, |
281 ;; but is used by math-map-over-constants-rec, which is called by | |
282 ;; math-map-over-constants. | |
283 (defvar math-moc-func) | |
284 | |
285 (defun math-map-over-constants (math-moc-func expr) | |
274 (math-map-over-constants-rec expr)) | 286 (math-map-over-constants-rec expr)) |
275 | 287 |
276 (defun math-map-over-constants-rec (expr) | 288 (defun math-map-over-constants-rec (expr) |
277 (cond ((or (Math-primp expr) | 289 (cond ((or (Math-primp expr) |
278 (memq (car expr) '(intv sdev))) | 290 (memq (car expr) '(intv sdev))) |
279 (or (and (Math-objectp expr) | 291 (or (and (Math-objectp expr) |
280 (funcall func expr)) | 292 (funcall math-moc-func expr)) |
281 expr)) | 293 expr)) |
282 ((and (memq (car expr) '(^ calcFunc-subscr)) | 294 ((and (memq (car expr) '(^ calcFunc-subscr)) |
283 (eq func 'math-float) | 295 (eq math-moc-func 'math-float) |
284 (= (length expr) 3) | 296 (= (length expr) 3) |
285 (Math-integerp (nth 2 expr))) | 297 (Math-integerp (nth 2 expr))) |
286 (list (car expr) | 298 (list (car expr) |
287 (math-map-over-constants-rec (nth 1 expr)) | 299 (math-map-over-constants-rec (nth 1 expr)) |
288 (nth 2 expr))) | 300 (nth 2 expr))) |
289 (t (cons (car expr) (mapcar 'math-map-over-constants-rec (cdr expr)))))) | 301 (t (cons (car expr) (mapcar 'math-map-over-constants-rec (cdr expr)))))) |
290 | 302 |
303 (provide 'calc-stuff) | |
304 | |
305 ;;; arch-tag: 789332ef-a178-49d3-8fb7-5d7ed7e21f56 | |
291 ;;; calc-stuff.el ends here | 306 ;;; calc-stuff.el ends here |