UnitsParse Module
Parses text to a Unit and appends the group of a unit to the text of the unit. The parse gives None for blank text, for a blank part and for more than three parts separated by a slash, and raises a FormatException for a unit with a factor of 0 or for text that does not parse and names a group other than General. Other text that does not parse becomes a General unit.
Functions and values
| Function or value |
Description
|
|
Creates a Unit from a string s, if possible, otherwise returns None. Note will take care of the n value of a unit! So, for example, the unit 36 hours can be parsed correctly. A unit with a factor of 0 cannot convert a value, so it raises a FormatException.
ExamplefromString "36 hours" = Some (Time (Hour 36N)) |
Full Usage:
groupIsGeneralOrNone s
Parameters:
string
Returns: bool
|
|
|
Whether a unit, or a part of a combined unit, has a factor of 0, as in 0 IU/ml.
|
Full Usage:
stringWithGroup u
Parameters:
string
Returns: string
|
Append a group to a string that represents a unit Example: stringWithGroup "mg" = "mg[Mass]"
|
GenPRES