units is a Common Lisp library that provides simple units conversion. The basis units for the library are the International System of Units (SI).
- Written in portable Common Lisp
- Can be used simply as a set of conversion functions
- Can be integrated into objects to track and check units in equations (sort of)
- Extensible with user defined units
- Performs simple dimensional analysis to create conversion factors for derived units.
At this preliminary stage, there is no documentation for the units library.
- Load using ASDF :
(asdf:load-system :units). - Convert a unit, for example 2.3 feet to meters:
(meter 2.3 foot) => 0.70104 - Define a base unit:
(define-base-unit inch meter 2.540D-2) - Define a derived unit:
(define-derived-unit inch^2 (* meter meter) 6.4516D-4)or simply(define-derived-unit inch^2 (* inch inch)).
Defining a unit binds a global variable of the unit name to the unit instance and creates a conversion function for that unit. Simple dimensional analysis of conversions is performed by the conversion function to verify that the target unit is compatible with the source unit.
NOTE: There is an small inconsistency in the naming convention for
the units. In general, units are named in the singular, except for
seconds. The seconds unit had to be plural to avoid a name clash
with cl:second.
- SI base units
meter,kilogram,seconds,ampere,kelvin,mole,candela - Angle units
radiananddegree - Time units
minute,hour, andday - US Customary units
inch,foot,yard,mile,nautical-mile,ounce,pound,ton,rankine
- Implement SI prefixes
- Expand the units defined in the library
- Document the library in the project wiki
- Expand dimensional analysis capabilities