diff options
| author | Jay Belanger | 2004-11-25 06:29:11 +0000 |
|---|---|---|
| committer | Jay Belanger | 2004-11-25 06:29:11 +0000 |
| commit | 3effaa28f58a5d1648ce8361ab11879397e2e580 (patch) | |
| tree | dac047132f32e0d7f08ba92891603ac3e0c250b5 | |
| parent | 95d91710e989602f6df1c63bef4e3e99700ec558 (diff) | |
| download | emacs-3effaa28f58a5d1648ce8361ab11879397e2e580.tar.gz emacs-3effaa28f58a5d1648ce8361ab11879397e2e580.zip | |
Finish making previous changes.
| -rw-r--r-- | lisp/calc/calc-units.el | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el index 03864ce3f07..9386dae8952 100644 --- a/lisp/calc/calc-units.el +++ b/lisp/calc/calc-units.el | |||
| @@ -665,25 +665,25 @@ Entries are (SYMBOL EXPR DOC-STRING TEMP-TYPE BASE-UNITS).") | |||
| 665 | (defvar math-fbu-base) | 665 | (defvar math-fbu-base) |
| 666 | (defvar math-fbu-entry) | 666 | (defvar math-fbu-entry) |
| 667 | 667 | ||
| 668 | (defun math-find-base-units (entry) | 668 | (defun math-find-base-units (math-fbu-entry) |
| 669 | (if (eq (nth 4 entry) 'boom) | 669 | (if (eq (nth 4 math-fbu-entry) 'boom) |
| 670 | (error "Circular definition involving unit %s" (car entry))) | 670 | (error "Circular definition involving unit %s" (car math-fbu-entry))) |
| 671 | (or (nth 4 entry) | 671 | (or (nth 4 math-fbu-entry) |
| 672 | (let (base) | 672 | (let (math-fbu-base) |
| 673 | (setcar (nthcdr 4 entry) 'boom) | 673 | (setcar (nthcdr 4 math-fbu-entry) 'boom) |
| 674 | (math-find-base-units-rec (nth 1 entry) 1) | 674 | (math-find-base-units-rec (nth 1 math-fbu-entry) 1) |
| 675 | '(or base | 675 | '(or math-fbu-base |
| 676 | (error "Dimensionless definition for unit %s" (car entry))) | 676 | (error "Dimensionless definition for unit %s" (car math-fbu-entry))) |
| 677 | (while (eq (cdr (car base)) 0) | 677 | (while (eq (cdr (car math-fbu-base)) 0) |
| 678 | (setq base (cdr base))) | 678 | (setq math-fbu-base (cdr math-fbu-base))) |
| 679 | (let ((b base)) | 679 | (let ((b math-fbu-base)) |
| 680 | (while (cdr b) | 680 | (while (cdr b) |
| 681 | (if (eq (cdr (car (cdr b))) 0) | 681 | (if (eq (cdr (car (cdr b))) 0) |
| 682 | (setcdr b (cdr (cdr b))) | 682 | (setcdr b (cdr (cdr b))) |
| 683 | (setq b (cdr b))))) | 683 | (setq b (cdr b))))) |
| 684 | (setq base (sort base 'math-compare-unit-names)) | 684 | (setq math-fbu-base (sort math-fbu-base 'math-compare-unit-names)) |
| 685 | (setcar (nthcdr 4 entry) base) | 685 | (setcar (nthcdr 4 math-fbu-entry) math-fbu-base) |
| 686 | base))) | 686 | math-fbu-base))) |
| 687 | 687 | ||
| 688 | (defun math-compare-unit-names (a b) | 688 | (defun math-compare-unit-names (a b) |
| 689 | (memq (car b) (cdr (memq (car a) math-cu-unit-list)))) | 689 | (memq (car b) (cdr (memq (car a) math-cu-unit-list)))) |
| @@ -694,10 +694,11 @@ Entries are (SYMBOL EXPR DOC-STRING TEMP-TYPE BASE-UNITS).") | |||
| 694 | (let ((ulist (math-find-base-units u))) | 694 | (let ((ulist (math-find-base-units u))) |
| 695 | (while ulist | 695 | (while ulist |
| 696 | (let ((p (* (cdr (car ulist)) pow)) | 696 | (let ((p (* (cdr (car ulist)) pow)) |
| 697 | (old (assq (car (car ulist)) base))) | 697 | (old (assq (car (car ulist)) math-fbu-base))) |
| 698 | (if old | 698 | (if old |
| 699 | (setcdr old (+ (cdr old) p)) | 699 | (setcdr old (+ (cdr old) p)) |
| 700 | (setq base (cons (cons (car (car ulist)) p) base)))) | 700 | (setq math-fbu-base |
| 701 | (cons (cons (car (car ulist)) p) math-fbu-base)))) | ||
| 701 | (setq ulist (cdr ulist))))) | 702 | (setq ulist (cdr ulist))))) |
| 702 | ((math-scalarp expr)) | 703 | ((math-scalarp expr)) |
| 703 | ((and (eq (car expr) '^) | 704 | ((and (eq (car expr) '^) |
| @@ -716,8 +717,8 @@ Entries are (SYMBOL EXPR DOC-STRING TEMP-TYPE BASE-UNITS).") | |||
| 716 | ((eq (car expr) 'var) | 717 | ((eq (car expr) 'var) |
| 717 | (or (eq (nth 1 expr) 'pi) | 718 | (or (eq (nth 1 expr) 'pi) |
| 718 | (error "Unknown name %s in defining expression for unit %s" | 719 | (error "Unknown name %s in defining expression for unit %s" |
| 719 | (nth 1 expr) (car entry)))) | 720 | (nth 1 expr) (car math-fbu-entry)))) |
| 720 | (t (error "Malformed defining expression for unit %s" (car entry)))))) | 721 | (t (error "Malformed defining expression for unit %s" (car math-fbu-entry)))))) |
| 721 | 722 | ||
| 722 | 723 | ||
| 723 | (defun math-units-in-expr-p (expr sub-exprs) | 724 | (defun math-units-in-expr-p (expr sub-exprs) |