Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 38 lines (29 sloc) 1.751 kB
2c480c7 @Ramarren Add GPLv2 header to all files.
authored
1 ;; unit-formulas - library for unit checked formula definitions
2 ;; Copyright (C) 2008 Jakub Higersberger
3
4 ;; This program is free software; you can redistribute it and/or modify
5 ;; it under the terms of the GNU General Public License as published by
6 ;; the Free Software Foundation; either version 2 of the License, or
7 ;; (at your option) any later version.
8
9 ;; This program is distributed in the hope that it will be useful,
10 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ;; GNU General Public License for more details.
13
14 ;; You should have received a copy of the GNU General Public License
15 ;; along with this program; if not, write to the Free Software
16 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
d591944 @Ramarren Initial commit.
authored
19 (in-package :unit-formulas)
20
21 (iter (for (unit-keyword unit-index) on *base-units* by #'cddr)
22 (for unit-instance = (make-instance 'unit))
23 (setf (aref (units-of unit-instance) unit-index) 1)
24 (setf (gethash (intern (symbol-name unit-keyword) :unit-formulas) *units*)
25 unit-instance))
26
27 (defmacro define-units (&rest unit-definitions)
28 `(progn ,@(iter (for (unit-names unit-definition) on unit-definitions by #'cddr)
29 (collect
30 `(let ((unit-instance (reduce-unit ',unit-definition)))
31 (iter (for name in ',(ensure-list unit-names))
99094e1 @Ramarren Fix typo
authored
32 (setf (gethash (intern (symbol-name name) (find-package :unit-formulas))
af3f11e @Ramarren Define units with names internet into unit-formulas package.
authored
33 *units*) unit-instance)))))))
d591944 @Ramarren Initial commit.
authored
34
35 (defmacro define-factors (unit &rest factor-definitions)
36 `(define-units ,@(iter (for (factor-names factor) on factor-definitions by #'cddr)
37 (appending `(,factor-names (,factor ,unit))))))
Something went wrong with that request. Please try again.