|
76 | 76 |
|
77 | 77 | Begin["`private`"];
|
78 | 78 |
|
| 79 | +If[$VersionNumber > 9., |
| 80 | + dispatchify[dispatch_Dispatch]:=Normal[dispatch], |
| 81 | + dispatchify[dispatch_Dispatch]:=dispatch[[1]] |
| 82 | +]; |
| 83 | + |
79 | 84 | (*Lists that store the unit coversion rules*)
|
80 | 85 | $ToFundamental={};
|
81 | 86 | $ExactUnitRules={};
|
|
103 | 108 | OptionValue[UsageMessage]
|
104 | 109 | ];
|
105 | 110 | Which[
|
106 |
| - Head[$ToFundamental]===Dispatch,existingrules=Normal[$ToFundamental];dispatchedq=True, |
| 111 | + Head[$ToFundamental]===Dispatch,existingrules=dispatchify[$ToFundamental];dispatchedq=True, |
107 | 112 | Head[$ToFundamental]===List,existingrules=$ToFundamental,
|
108 | 113 | True,existingrules={}];
|
109 | 114 | (*If unit name is already decalared, issue warning and over-write definition*)
|
|
122 | 127 | (*If relationship is exact, store it explicitely *)
|
123 | 128 | If[Precision[val[[1]]]===Infinity,
|
124 | 129 | Which[
|
125 |
| - Head[$ExactUnitRules]===Dispatch,existingexactrules=Normal[$ExactUnitRules];dispatchedq=True, |
| 130 | + Head[$ExactUnitRules]===Dispatch,existingexactrules=dispatchify[$ExactUnitRules];dispatchedq=True, |
126 | 131 | Head[$ExactUnitRules]===List,existingexactrules=$ExactUnitRules,
|
127 | 132 | True,existingrules={}
|
128 | 133 | ];
|
|
155 | 160 | application of Dispatch by doing it just once at the end. This gives much faster package initialization*)
|
156 | 161 | FastGroupDeclareUnit[expr_]:=Block[{$UnitInitialization=True,newfund,newexact,junk},
|
157 | 162 | (*Make sure that the tables are plain lists*)
|
158 |
| - If[Head[$ToFundamental]===Dispatch,$ToFundamental=Normal[$ToFundamental]]; |
| 163 | + If[Head[$ToFundamental]===Dispatch,$ToFundamental=dispatchify[$ToFundamental]]; |
159 | 164 | If[Head[$ToFundamental]===List,$ToFundamental={}];
|
160 |
| - If[Head[$ExactUnitRules]===Dispatch,$ExactUnitRules=Normal[$ExactUnitRules]]; |
| 165 | + If[Head[$ExactUnitRules]===Dispatch,$ExactUnitRules=dispatchify[$ExactUnitRules]]; |
161 | 166 | If[Head[$ExactUnitRules]===List,$ExactUnitRules={}];
|
162 | 167 |
|
163 | 168 | (*expr should be a CompoundExpression of DeclareUnit expressions*)
|
|
1131 | 1136 | NotebookWrite[InputNotebook[], ToBoxes[#,
|
1132 | 1137 | If[tradform,TraditionalForm,StandardForm]]],Appearance -> "Palette"],
|
1133 | 1138 | TraditionalForm[#]] &
|
1134 |
| - |
| 1139 | + |
1135 | 1140 | End[];
|
1136 | 1141 |
|
1137 |
| -Quiet[ |
| 1142 | + |
1138 | 1143 | DeclareUnit["Molecule"];
|
1139 | 1144 | DeclareUnit["Mole",Unit[6.0221415`*^23,"Molecule"]];
|
1140 | 1145 | AutomaticUnits`private`SIPrefixify["Mole","Substance amount","mol"];
|
1141 | 1146 | UnitSet["SI"]=Join[UnitSet["SI"]/.Meter^3->Liter,{Millimole,Millimole Liter^-1}];
|
1142 |
| -] |
1143 | 1147 |
|
1144 | 1148 | EndPackage[]
|
1145 | 1149 |
|
0 commit comments