blob: fdf8e27d659cc01db01d9a2e440cf8fdb70f2f57 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
(.module:
[library
[lux {"-" [and]}
["$" documentation {"+" [documentation:]}]
[control
["<>" parser
["<[0]>" code]]]
[data
["[0]" text {"+" [\n]}
["%" format {"+" [format]}]]]
[macro
["[0]" template]]
[math
[number
["[0]" ratio]]]]]
[\\library
["[0]" /]])
(documentation: (/.Qty unit)
"A quantity with an associated unit of measurement.")
(documentation: (/.Unit unit)
"A unit of measurement, to qualify numbers with.")
(documentation: (/.Scale scale)
"A scale of magnitude.")
(documentation: /.Pure
"A pure, unit-less quantity.")
(documentation: /.unit:
(format "Define a unit of measurement."
\n "Both the name of the type, and the name of the Unit implementation must be specified.")
[(unit: .public Feet feet)])
(documentation: /.scale:
"Define a scale of magnitude."
[(scale: .public Bajillion bajillion
[1 1,234,567,890])])
(documentation: /.re_scaled
""
[(re_scaled from to quantity)])
(template [<type> <scale>]
[(`` (documentation: <scale>
(let [numerator (value@ [#/.ratio #ratio.numerator] <scale>)
denominator (value@ [#/.ratio #ratio.denominator] <scale>)]
(format "The '" (~~ (template.text [<scale>])) "' scale, from " (%.nat numerator) " to " (%.nat denominator) "."))))]
[/.Kilo /.kilo]
[/.Mega /.mega]
[/.Giga /.giga]
[/.Milli /.milli]
[/.Micro /.micro]
[/.Nano /.nano]
)
(template [<unit>]
[(`` (documentation: <unit>
(format "The '" (~~ (template.text [<unit>])) "' unit of meaurement.")))]
[/.gram]
[/.meter]
[/.litre]
[/.second]
)
(.def: .public documentation
(.List $.Module)
($.module /._
""
[..Qty
..Unit
..Scale
..Pure
..unit:
..scale:
..re_scaled
..kilo
..mega
..giga
..milli
..micro
..nano
..gram
..meter
..litre
..second
($.default /.Gram)
($.default /.Meter)
($.default /.Litre)
($.default /.Second)
($.default /.pure)
($.default /.number)
($.default /.equivalence)
($.default /.order)
($.default /.enum)
($.default /.Kilo)
($.default /.Mega)
($.default /.Giga)
($.default /.Milli)
($.default /.Micro)
($.default /.Nano)
($.default /.+)
($.default /.-)
($.default /.*)
($.default /./)]
[]))
|