[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Engineering numbers ..



Hi,

I think we have exactly the read macros you asked for. My colleague
Roman Cunis developed a measures package that even handles conversions
between different units. I already convinced him to make his code
public. However, the documentation is in German.

Maybe he will translate it if someone would like to have the code.
The code has been tested in Allegro CL, Symbolics CL, Macintosh CL,
and Harlequin CL.

Example:

(in-package :cl-user)

(use-package :measures)

(define-unit |m| :base length :metric)

(define-unit |qm| |m| |m| :base area)
(define-unit |qkm| |km| |km|)
(define-unit |ar| 100 |qm|)
(define-unit |ha| 100 |ar|)

(define-unit |m3| |m| |m| |m| :base volume)
(define-unit |ccm| |cm| |cm| |cm|)
(define-unit |l| 1000 |ccm|)

(define-unit |s| :base time)
(define-unit |min| 60 |s|)
(define-unit |h| 60 |min|)
(define-unit |ms| 0.001 |s|)

(define-unit |m/s| |m| |/s| :base speed)
(define-unit |km/h| |km| |/h|)

(define-unit DM :base currency)
(define-unit |Pfg| 0.01 DM)
(define-unit $ 1.85 DM)
(define-unit |c| 0.01 $)

(define-unit-format time :step |h| |min| |s|)
(define-unit-format speed :unit |km/h|)
(define-unit-format length :base)



Application:

? (dim+ 1m 4cm)
1.04m

? (dim+ 1min 46s 4ms)
1min:46.004s

? (dim+ 3h (dim+ 1min 46s 4ms))
3h:1min:46.004s

====================================================================

Interested?


Ralf 


========================================

Ralf Moeller
University of Hamburg
Bodenstedtstr. 16
2000 Hamburg 50
Germany

Phone: ++40 4123 6134
Fax ++40 4123 6530
Email: moeller@informatik.uni-hamburg.de