Coverage report: /home/ellis/comp/core/std/macs/unit.lisp

KindCoveredAll%
expression026 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; std/macs/unit.lisp
2
 
3
 ;;
4
 
5
 ;;; Commentary:
6
 
7
 ;; ref: https://www.dot.state.wy.us/files/live/sites/wydot/files/shared/Highway_Development/Surveys/Survey%20Manual/Appendix%20G%20-%20Units%20of%20Measure.pdf
8
 
9
 ;;; Code:
10
 (in-package :std/macs)
11
 
12
 (defmacro! defunits (quantity base-unit &rest units)
13
   `(progn
14
      (defmacro ,(symbolicate 'unit-of- quantity) (,g!val ,g!un)
15
        `(* ,,g!val
16
            ,(case ,g!un
17
               ((,base-unit) 1)
18
               ,@(mapcar (lambda (x)
19
                           `((,(car x))
20
                             ,(std/prim::defunits-chaining
21
                                  (car x)
22
                                  (cons
23
                                   `(,base-unit 1)
24
                                   (group units 2))
25
                                nil)))
26
                  (group units 2)))))
27
      (deftype ,(symbolicate quantity '-designator) ()
28
        '(member ,@(loop for k in units by 'cddr
29
                         collect (keywordicate k))))))
30
 
31
 ;;; Distance
32
 (defunits distance m
33
   km 1000
34
   cm 1/100
35
   mm (1/10 cm)
36
   nm (1/1000 mm)
37
   yard 9144/10000 ; Defined in 1956
38
   foot (1/3 yard)
39
   inch (1/12 foot)
40
   mile (1760 yard)
41
   furlong (1/8 mile)
42
   fathom (2 yard) ; Defined in 1929
43
   nautical-mile 1852
44
   cable (1/10 nautical-mile)
45
   light-year (9.4607e+12 mile))