Changeset 17924 in project


Ignore:
Timestamp:
04/26/10 13:11:35 (9 years ago)
Author:
Ivan Raikov
Message:

updated unitconv documentation

Location:
release/4/unitconv/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/unitconv/trunk/unitconv-eggdoc.scm

    r15185 r17924  
    99
    1010     (history
     11      (version "2.0" "Added unit arithmetic (with-units)")
    1112      (version "1.8" "Exporting all prefixed units; added info on information units [Joshua Griffith]")
    1213      (version "1.7" "Exporting the Rate quantity")
     
    2122     (requires)
    2223
    23      (usage "(require-extension unitconv)"
    24             "(include \"unit-definitions\")")
    25 
    26      (download "unitconv.egg")
     24     (usage "(require-extension unitconv)")
    2725
    2826     (documentation
     
    292290             (define-unit bytes-per-second  Rate  (/ byte second)  Bps)
    293291             ))
     292
     293(subsection "Arithmetic Operations with Units"
     294           
     295
     296            (p "The " (tt "with-units") " library contains procedures for arithmetic operations "
     297               "on quantities with units. A quantity with unit information is created by procedure "
     298               (code "val-with-units")  ": "
     299
     300    (pre #<<EOF
     301(use unitconv with-units)
     302(val-with-units 10 m) ->  #(10 #(unit meter (m meters) [Length] 1.0))
     303EOF
     304))
     305
     306            (p "The following operations are available for operations on quantities with units: "
     307
     308            (dl
     309             (dt (tt "u:value") (dd "Returns the value of the given quantity."))
     310             (dt (tt "u:units") (dd "Returns the unit of the given quantity."))
     311             (dt (tt "u:equal?") (dd "Returns true if the units of the given quantities are equal, false otherwise."))
     312             (dt (tt "u:zero?"))
     313             (dt (tt "u:="))
     314             (dt (tt "u:negate"))
     315             (dt (tt "u:invert"))
     316             (dt (tt "u:+ u:- u:* u:/ "))
     317             (dt (tt "u:sqrt"))
     318             (dt (tt "u:sin"))
     319             (dt (tt "u:cos"))
     320             (dt (tt "u:expt"))
     321            )
     322
     323            ))
    294324   )
    295325 
     
    320350csi> (unit-convert inch mm 12)
    321351304.8
     352
     353;; Unit arithmetic
     354
     355csi> (use with-units)
     356csi>  (u:+ (val-with-units 10 m) (val-with-units 5 m))
     357#(15 #(unit meter (m meters) [Length] 1.0))
     358
    322359EOF
    323360))
     
    325362
    326363     (license
    327 "Copyright 2007-2009 Ivan Raikov.
     364"Copyright 2007-2010 Ivan Raikov.
    328365
    329366This program is free software: you can redistribute it and/or modify
  • release/4/unitconv/trunk/with-units.scm

    r17915 r17924  
    129129                  (or (without-units? x) (without-units? y)))
    130130             (+ (u:value x) (u:value y)))
    131             (else (error "units do not match: +" x y)))
     131            (else (error 'u:+ "units do not match: " x y)))
    132132      (val-with-units(+ x y)  unitless )))
    133133
     
    141141                  (or (without-units? x) (without-units? y)))
    142142             (- (u:value x) (u:value y)))
    143             (else (error "units do not match: -" x y)))
     143            (else (error 'u:- "units do not match: " x y)))
    144144      (val-with-units (- x y) unitless)))
    145145
     
    161161          (val-with-units (expt (u:value x) (u:value y))
    162162                          (unit-expt (u:units x) (u:value y)))
    163           (error "exponent must be unitless: expt" x y))
     163          (error 'u:expt "exponent must be unitless:" x y))
    164164      (val-with-units (expt x y) unitless)))
    165165
Note: See TracChangeset for help on using the changeset viewer.