[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/calc/calc-units.el
From: |
Jay Belanger |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/calc/calc-units.el |
Date: |
Thu, 25 Nov 2004 01:50:51 -0500 |
Index: emacs/lisp/calc/calc-units.el
diff -c emacs/lisp/calc/calc-units.el:1.10 emacs/lisp/calc/calc-units.el:1.11
*** emacs/lisp/calc/calc-units.el:1.10 Thu Nov 25 05:53:35 2004
--- emacs/lisp/calc/calc-units.el Thu Nov 25 06:29:11 2004
***************
*** 665,689 ****
(defvar math-fbu-base)
(defvar math-fbu-entry)
! (defun math-find-base-units (entry)
! (if (eq (nth 4 entry) 'boom)
! (error "Circular definition involving unit %s" (car entry)))
! (or (nth 4 entry)
! (let (base)
! (setcar (nthcdr 4 entry) 'boom)
! (math-find-base-units-rec (nth 1 entry) 1)
! '(or base
! (error "Dimensionless definition for unit %s" (car entry)))
! (while (eq (cdr (car base)) 0)
! (setq base (cdr base)))
! (let ((b base))
(while (cdr b)
(if (eq (cdr (car (cdr b))) 0)
(setcdr b (cdr (cdr b)))
(setq b (cdr b)))))
! (setq base (sort base 'math-compare-unit-names))
! (setcar (nthcdr 4 entry) base)
! base)))
(defun math-compare-unit-names (a b)
(memq (car b) (cdr (memq (car a) math-cu-unit-list))))
--- 665,689 ----
(defvar math-fbu-base)
(defvar math-fbu-entry)
! (defun math-find-base-units (math-fbu-entry)
! (if (eq (nth 4 math-fbu-entry) 'boom)
! (error "Circular definition involving unit %s" (car math-fbu-entry)))
! (or (nth 4 math-fbu-entry)
! (let (math-fbu-base)
! (setcar (nthcdr 4 math-fbu-entry) 'boom)
! (math-find-base-units-rec (nth 1 math-fbu-entry) 1)
! '(or math-fbu-base
! (error "Dimensionless definition for unit %s" (car math-fbu-entry)))
! (while (eq (cdr (car math-fbu-base)) 0)
! (setq math-fbu-base (cdr math-fbu-base)))
! (let ((b math-fbu-base))
(while (cdr b)
(if (eq (cdr (car (cdr b))) 0)
(setcdr b (cdr (cdr b)))
(setq b (cdr b)))))
! (setq math-fbu-base (sort math-fbu-base 'math-compare-unit-names))
! (setcar (nthcdr 4 math-fbu-entry) math-fbu-base)
! math-fbu-base)))
(defun math-compare-unit-names (a b)
(memq (car b) (cdr (memq (car a) math-cu-unit-list))))
***************
*** 694,703 ****
(let ((ulist (math-find-base-units u)))
(while ulist
(let ((p (* (cdr (car ulist)) pow))
! (old (assq (car (car ulist)) base)))
(if old
(setcdr old (+ (cdr old) p))
! (setq base (cons (cons (car (car ulist)) p) base))))
(setq ulist (cdr ulist)))))
((math-scalarp expr))
((and (eq (car expr) '^)
--- 694,704 ----
(let ((ulist (math-find-base-units u)))
(while ulist
(let ((p (* (cdr (car ulist)) pow))
! (old (assq (car (car ulist)) math-fbu-base)))
(if old
(setcdr old (+ (cdr old) p))
! (setq math-fbu-base
! (cons (cons (car (car ulist)) p) math-fbu-base))))
(setq ulist (cdr ulist)))))
((math-scalarp expr))
((and (eq (car expr) '^)
***************
*** 716,723 ****
((eq (car expr) 'var)
(or (eq (nth 1 expr) 'pi)
(error "Unknown name %s in defining expression for unit %s"
! (nth 1 expr) (car entry))))
! (t (error "Malformed defining expression for unit %s" (car entry))))))
(defun math-units-in-expr-p (expr sub-exprs)
--- 717,724 ----
((eq (car expr) 'var)
(or (eq (nth 1 expr) 'pi)
(error "Unknown name %s in defining expression for unit %s"
! (nth 1 expr) (car math-fbu-entry))))
! (t (error "Malformed defining expression for unit %s" (car
math-fbu-entry))))))
(defun math-units-in-expr-p (expr sub-exprs)