aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2007-09-26 00:08:16 +0000
committerJuanma Barranquero2007-09-26 00:08:16 +0000
commit09040c8d89ea6ccd353daf9cdfffca3e910dba5f (patch)
tree68d16cba28fecf0f39efd8c0f542f08e209c8f8d
parent4d2a9fe4a44aa3c718b6584910e51f30ad241002 (diff)
downloademacs-09040c8d89ea6ccd353daf9cdfffca3e910dba5f.tar.gz
emacs-09040c8d89ea6ccd353daf9cdfffca3e910dba5f.zip
(math-build-units-table): Use `mapc' rather than `mapcar'.
-rw-r--r--lisp/calc/calc-units.el40
1 files changed, 20 insertions, 20 deletions
diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el
index 3724490169a..14ab00791d3 100644
--- a/lisp/calc/calc-units.el
+++ b/lisp/calc/calc-units.el
@@ -54,7 +54,7 @@
54 ( ft "12 in" "Foot" ) 54 ( ft "12 in" "Foot" )
55 ( yd "3 ft" "Yard" ) 55 ( yd "3 ft" "Yard" )
56 ( mi "5280 ft" "Mile" ) 56 ( mi "5280 ft" "Mile" )
57 ( au "149597870691. m" "Astronomical Unit" ) 57 ( au "149597870691. m" "Astronomical Unit" )
58 ;; (approx) NASA JPL (http://neo.jpl.nasa.gov/glossary/au.html) 58 ;; (approx) NASA JPL (http://neo.jpl.nasa.gov/glossary/au.html)
59 ( lyr "c yr" "Light Year" ) 59 ( lyr "c yr" "Light Year" )
60 ( pc "3.0856775854e16 m" "Parsec" ) ;; (approx) ESUWM 60 ( pc "3.0856775854e16 m" "Parsec" ) ;; (approx) ESUWM
@@ -91,7 +91,7 @@
91 ( tbsp "3 tsp" "Tablespoon" ) 91 ( tbsp "3 tsp" "Tablespoon" )
92 ;; ESUWM defines a US gallon as 231 in^3. 92 ;; ESUWM defines a US gallon as 231 in^3.
93 ;; That gives the following exact value for tsp. 93 ;; That gives the following exact value for tsp.
94 ( tsp "492892159375*10^(-11) ml" "Teaspoon" ) 94 ( tsp "492892159375*10^(-11) ml" "Teaspoon" )
95 ( vol "tsp+tbsp+ozfl+cup+pt+qt+gal" "Gallons + ... + teaspoons" ) 95 ( vol "tsp+tbsp+ozfl+cup+pt+qt+gal" "Gallons + ... + teaspoons" )
96 ( galC "galUK" "Canadian Gallon" ) 96 ( galC "galUK" "Canadian Gallon" )
97 ( galUK "454609*10^(-5) L" "UK Gallon" ) ;; NIST 97 ( galUK "454609*10^(-5) L" "UK Gallon" ) ;; NIST
@@ -342,13 +342,13 @@ Entries are (SYMBOL EXPR DOC-STRING TEMP-TYPE BASE-UNITS).")
342If EXPR is nil, return nil." 342If EXPR is nil, return nil."
343 (if expr 343 (if expr
344 (let ((cexpr (math-compose-expr expr 0))) 344 (let ((cexpr (math-compose-expr expr 0)))
345 (replace-regexp-in-string 345 (replace-regexp-in-string
346 " / " "/" 346 " / " "/"
347 (if (stringp cexpr) 347 (if (stringp cexpr)
348 cexpr 348 cexpr
349 (math-composition-to-string cexpr)))))) 349 (math-composition-to-string cexpr))))))
350 350
351(defvar math-default-units-table 351(defvar math-default-units-table
352 (make-hash-table :test 'equal) 352 (make-hash-table :test 'equal)
353 "A table storing previously converted units.") 353 "A table storing previously converted units.")
354 354
@@ -356,7 +356,7 @@ If EXPR is nil, return nil."
356 "Get default units to use when converting the units in EXPR." 356 "Get default units to use when converting the units in EXPR."
357 (let* ((units (math-get-units expr)) 357 (let* ((units (math-get-units expr))
358 (standard-units (math-get-standard-units expr)) 358 (standard-units (math-get-standard-units expr))
359 (default-units (gethash 359 (default-units (gethash
360 standard-units 360 standard-units
361 math-default-units-table))) 361 math-default-units-table)))
362 (if (equal units (car default-units)) 362 (if (equal units (car default-units))
@@ -403,7 +403,7 @@ If EXPR is nil, return nil."
403 (setq expr (math-mul expr uold)))) 403 (setq expr (math-mul expr uold))))
404 (unless new-units 404 (unless new-units
405 (setq defunits (math-get-default-units expr)) 405 (setq defunits (math-get-default-units expr))
406 (setq new-units 406 (setq new-units
407 (read-string (concat 407 (read-string (concat
408 (if uoldname 408 (if uoldname
409 (concat "Old units: " 409 (concat "Old units: "
@@ -416,7 +416,7 @@ If EXPR is nil, return nil."
416 defunits 416 defunits
417 "): ") 417 "): ")
418 ": ")))) 418 ": "))))
419 419
420 (if (and 420 (if (and
421 (string= new-units "") 421 (string= new-units "")
422 defunits) 422 defunits)
@@ -476,7 +476,7 @@ If EXPR is nil, return nil."
476 (setq defunits (math-get-default-units expr)) 476 (setq defunits (math-get-default-units expr))
477 (setq unew (or new-units 477 (setq unew (or new-units
478 (math-read-expr 478 (math-read-expr
479 (read-string 479 (read-string
480 (concat 480 (concat
481 (if uoldname 481 (if uoldname
482 (concat "Old temperature units: " 482 (concat "Old temperature units: "
@@ -507,7 +507,7 @@ If EXPR is nil, return nil."
507 (calc-enter-result 1 "rmun" (math-simplify-units 507 (calc-enter-result 1 "rmun" (math-simplify-units
508 (math-extract-units (calc-top-n 1)))))) 508 (math-extract-units (calc-top-n 1))))))
509 509
510;; The variables calc-num-units and calc-den-units are local to 510;; The variables calc-num-units and calc-den-units are local to
511;; calc-explain-units, but are used by calc-explain-units-rec, 511;; calc-explain-units, but are used by calc-explain-units-rec,
512;; which is called by calc-explain-units. 512;; which is called by calc-explain-units.
513(defvar calc-num-units) 513(defvar calc-num-units)
@@ -752,7 +752,7 @@ If EXPR is nil, return nil."
752 (list (cons (car x) 1)))))) 752 (list (cons (car x) 1))))))
753 combined-units)) 753 combined-units))
754 (let ((math-units-table tab)) 754 (let ((math-units-table tab))
755 (mapcar 'math-find-base-units tab)) 755 (mapc 'math-find-base-units tab))
756 (message "Building units table...done") 756 (message "Building units table...done")
757 (setq math-units-table tab)))) 757 (setq math-units-table tab))))
758 758
@@ -794,7 +794,7 @@ If EXPR is nil, return nil."
794 (old (assq (car (car ulist)) math-fbu-base))) 794 (old (assq (car (car ulist)) math-fbu-base)))
795 (if old 795 (if old
796 (setcdr old (+ (cdr old) p)) 796 (setcdr old (+ (cdr old) p))
797 (setq math-fbu-base 797 (setq math-fbu-base
798 (cons (cons (car (car ulist)) p) math-fbu-base)))) 798 (cons (cons (car (car ulist)) p) math-fbu-base))))
799 (setq ulist (cdr ulist))))) 799 (setq ulist (cdr ulist)))))
800 ((math-scalarp expr)) 800 ((math-scalarp expr))
@@ -988,8 +988,8 @@ If EXPR is nil, return nil."
988 (if (equal (nth 4 math-fcu-u) (nth 4 u2)) 988 (if (equal (nth 4 math-fcu-u) (nth 4 u2))
989 (cons expr pow)))))) 989 (cons expr pow))))))
990 990
991;; The variables math-cu-new-units and math-cu-pure are local to 991;; The variables math-cu-new-units and math-cu-pure are local to
992;; math-convert-units, but are used by math-convert-units-rec, 992;; math-convert-units, but are used by math-convert-units-rec,
993;; which is called by math-convert-units. 993;; which is called by math-convert-units.
994(defvar math-cu-new-units) 994(defvar math-cu-new-units)
995(defvar math-cu-pure) 995(defvar math-cu-pure)
@@ -1001,7 +1001,7 @@ If EXPR is nil, return nil."
1001 (if (eq (car-safe (nth 1 unew)) '+) 1001 (if (eq (car-safe (nth 1 unew)) '+)
1002 (setq math-cu-new-units (nth 1 unew))))) 1002 (setq math-cu-new-units (nth 1 unew)))))
1003 (math-with-extra-prec 2 1003 (math-with-extra-prec 2
1004 (let ((compat (and (not math-cu-pure) 1004 (let ((compat (and (not math-cu-pure)
1005 (math-find-compatible-unit expr math-cu-new-units))) 1005 (math-find-compatible-unit expr math-cu-new-units)))
1006 (math-cu-unit-list nil) 1006 (math-cu-unit-list nil)
1007 (math-combining-units nil)) 1007 (math-combining-units nil))
@@ -1028,7 +1028,7 @@ If EXPR is nil, return nil."
1028 1028
1029(defun math-convert-units-rec (expr) 1029(defun math-convert-units-rec (expr)
1030 (if (math-units-in-expr-p expr nil) 1030 (if (math-units-in-expr-p expr nil)
1031 (math-apply-units (math-to-standard-units 1031 (math-apply-units (math-to-standard-units
1032 (list '/ expr math-cu-new-units) nil) 1032 (list '/ expr math-cu-new-units) nil)
1033 math-cu-new-units math-cu-unit-list math-cu-pure) 1033 math-cu-new-units math-cu-unit-list math-cu-pure)
1034 (if (Math-primp expr) 1034 (if (Math-primp expr)
@@ -1093,7 +1093,7 @@ If EXPR is nil, return nil."
1093 (calc-record-why "*Inconsistent units" math-simplify-expr) 1093 (calc-record-why "*Inconsistent units" math-simplify-expr)
1094 math-simplify-expr) 1094 math-simplify-expr)
1095 (list '* (math-add (math-remove-units (nth 1 math-simplify-expr)) 1095 (list '* (math-add (math-remove-units (nth 1 math-simplify-expr))
1096 (if (eq (car math-simplify-expr) '-) 1096 (if (eq (car math-simplify-expr) '-)
1097 (math-neg ratio) ratio)) 1097 (math-neg ratio) ratio))
1098 units))))) 1098 units)))))
1099 1099
@@ -1187,7 +1187,7 @@ If EXPR is nil, return nil."
1187 (math-simplify-units-divisor np (cdr (cdr math-simplify-expr))) 1187 (math-simplify-units-divisor np (cdr (cdr math-simplify-expr)))
1188 (if (eq math-try-cancel-units 0) 1188 (if (eq math-try-cancel-units 0)
1189 (let* ((math-simplifying-units nil) 1189 (let* ((math-simplifying-units nil)
1190 (base (math-simplify 1190 (base (math-simplify
1191 (math-to-standard-units math-simplify-expr nil)))) 1191 (math-to-standard-units math-simplify-expr nil))))
1192 (if (Math-numberp base) 1192 (if (Math-numberp base)
1193 (setq math-simplify-expr base)))) 1193 (setq math-simplify-expr base))))
@@ -1243,11 +1243,11 @@ If EXPR is nil, return nil."
1243 (math-realp (nth 2 math-simplify-expr)) 1243 (math-realp (nth 2 math-simplify-expr))
1244 (if (memq (car-safe (nth 1 math-simplify-expr)) '(* /)) 1244 (if (memq (car-safe (nth 1 math-simplify-expr)) '(* /))
1245 (list (car (nth 1 math-simplify-expr)) 1245 (list (car (nth 1 math-simplify-expr))
1246 (list '^ (nth 1 (nth 1 math-simplify-expr)) 1246 (list '^ (nth 1 (nth 1 math-simplify-expr))
1247 (nth 2 math-simplify-expr)) 1247 (nth 2 math-simplify-expr))
1248 (list '^ (nth 2 (nth 1 math-simplify-expr)) 1248 (list '^ (nth 2 (nth 1 math-simplify-expr))
1249 (nth 2 math-simplify-expr))) 1249 (nth 2 math-simplify-expr)))
1250 (math-simplify-units-pow (nth 1 math-simplify-expr) 1250 (math-simplify-units-pow (nth 1 math-simplify-expr)
1251 (nth 2 math-simplify-expr))))) 1251 (nth 2 math-simplify-expr)))))
1252 1252
1253(math-defsimplify calcFunc-sqrt 1253(math-defsimplify calcFunc-sqrt