Units Module
Holds the details of every known unit and creates, compares, looks up and formats units in English or Dutch.
Types and nested modules
| Type/Module | Description |
|
Creates the body surface area unit square meter with a given value or with the value 1. |
|
|
Creates a Count unit with a given value or with the value 1. |
|
|
Creates the Distance units meter, centimeter and millimeter with a given value or with the value 1. |
|
|
Creates the Energy units calorie and kilocalorie with a given value or with the value 1. |
|
|
Creates a General unit with a name and a value, or with a name and the value 1. The function general, which sets the value 1, raises an ArgumentException for a blank name. |
|
|
Creates the Height units meter and centimeter with a given value or with the value 1. |
|
|
Creates the international units million IU, IU and milli IU with a given value or with the value 1. |
|
|
Creates the Mass units kilogram, gram, milligram, microgram and nanogram with a given value or with the value 1. |
|
|
Creates the Molar units mole, millimole and micromole with a given value or with the value 1. |
|
|
Creates the Time units year, month, week, day, hour, minute and second with a given value or with the value 1. |
|
|
Creates and reads the details of a unit and holds the list with the group, abbreviations, names and synonyms of every known unit. |
|
|
Creates the Volume units liter, deciliter, milliliter, microliter and droplet with a given value or with the value 1. A droplet unit holds the number of droplets per milliliter, 20 unless set otherwise. |
|
|
Creates the Weight units kilogram and gram with a given value or with the value 1. |
|
|
|
|
|
|
|
|
|
|
|
|
Functions and values
| Function or value |
Description
|
Full Usage:
apply f u
Parameters:
BigRational -> BigRational
-
the function to apply to the unit value
u : Unit
-
the unit
Returns: Unit
The unit with the updated value
|
Apply a function f to the unit value(s) of unit u.
Exampleapply (fun n -> n * 2N) (Mass (KiloGram 1N)) = Mass (KiloGram 2N) |
|
Check whether unit u1 equals unit u2 irrespective of the unit value.
The unit value is ignored for every unit type EXCEPT
|
|
Get the Dutch language string
ExamplegetDutch { Eng = "abc"; EngPlural = "abcs"; Dut = "def"; DutchPlural = "defs" } = "def" |
|
Get the English language string
ExamplegetEnglish { Eng = "abc"; EngPlural = "abcs"; Dut = "def"; DutchPlural = "defs" } = "abc" |
|
|
|
|
|
|
|
Change the value of a unit to the value n Example: (Mass (KiloGram 1N)) |> setUnitValue 2N = Mass (KiloGram 2N)
|
Full Usage:
toString vw uw hasGroup loc verb u
Parameters:
string option
-
Optional unit value wrapper
uw : string option
-
Optional unit wrapper
hasGroup : bool
-
When true, includes the unit group in brackets (e.g., "[Mass]"); when false, omits it
loc : Localization
-
Localization (English or Dutch)
verb : Verbal
-
Verbality (Short or Long)
u : Unit
-
The unit to convert to string
Returns: string
|
Turn a unit u to a string with localization, verbality, and optional group annotation.
|
|
Turn a unit to a dutch long string with group annotation
ExampletoStringDutchLong (Time (Minute 1N)) = "minuut[Time]" |
|
Turn a unit to a dutch short string with group annotation
ExampletoStringDutchShort (Time (Minute 1N)) = "min[Time]" |
Full Usage:
toStringDutchShortWithWrapper vw uw
Parameters:
string
uw : string
Returns: Unit -> string
|
Turn a unit to a dutch short string with group annotation
ExampletoStringDutchShort (Time (Minute 1N)) = "min[Time]" |
|
Turn a unit to an english long string with group annotation
ExampletoStringEngLong (Time (Day 1N)) = "day[Time]" |
|
Turn a unit to an english short string with group annotation
ExampletoStringEngShort (Time (Day 1N)) = "day[Time]" |
|
Turn a unit to an english short string without group annotation
ExampletoStringEngShort (Time (Day 1N)) = "day" |
|
Try find unit details in the list of units for unit u Example: tryFind (Mass.kiloGram) = Some { ... }
|
GenPRES