ValueUnit Module
Creates a ValueUnit, converts it between units, calculates with and compares ValueUnits with unit simplification, and formats and parses a ValueUnit.
Nested modules
| Modules | Description |
|
Maps a ValueUnit to a Dto with the values, the unit and the group as text, and back. The mapping to a Dto gives None for a language other than English or Dutch. The mapping back reads the unit from the Json text when the Dto has one, and otherwise parses the unit with its group: a blank unit gives None, an unknown unit with no group or the group General becomes a General unit, and an unknown unit with another group raises a FormatException. |
|
|
Exposes the Group type and the functions of the Group module under the older name ValueUnit.Group, so code that uses the older name keeps compiling. The module is a full module rather than a module abbreviation, so that its members are exported to other assemblies. |
|
|
Holds the multiplier of every unit to its base unit and converts a value between a unit and the base unit. |
|
|
Holds the infix operators to calculate with, compare and convert ValueUnits. |
Functions and values
| Function or value |
Description
|
Full Usage:
applyToValue fValue vu
Parameters:
BigRational[] -> RationalX[]
-
The function to apply to the Value
vu : ValueUnit
-
The ValueUnit
Returns: ValueUnit
The updated ValueUnit
|
Apply a function fValue to the Value of a ValueUnit vu
Example
val fValue: (obj array -> obj array)
module Array
from Microsoft.FSharp.Collections
val map: mapping: ('T -> 'U) -> array: 'T array -> 'U array
|
|
Build a unit from a list of numerators and denominators. Uses an accumulator to build the unit and a boolean to indicate whether there is a count unit in the numerator. isCount is true when there is a count unit in the numerator and false when there is no count unit in the numerator. Note when ns = ds then the result is isCount = true and u = NoUnit
|
Full Usage:
calc b op vu1 vu2
Parameters:
bool
-
Whether to simplify the result
op : BigRational -> BigRational -> BigRational
-
The operator to apply
vu1 : ValueUnit
-
The first ValueUnit
vu2 : ValueUnit
-
The second ValueUnit
Returns: ValueUnit
The result of applying the operator to the ValueUnits
|
Calculate a ValueUnit by applying an operator op to ValueUnit vu1 and vu2. The operator can be addition, subtraction, multiplication or division. The boolean b results in whether the result is simplified. fails when adding or subtracting different units
Example
|
Full Usage:
cmp cp vu1 vu2
Parameters:
BigRational -> BigRational -> bool
-
The operator to use
vu1 : ValueUnit
-
The first ValueUnit
vu2 : ValueUnit
-
The second ValueUnit
Returns: bool
True if the comparison is true, false otherwise
|
Compare a ValueUnit vu1 with vu2.Comparison can be: greater, greater or equal, smaller, smaller or equal. Checks if the comparison is true for all individual values. Doesn't work for equal.
Example
|
|
|
|
Check if ValueUnit vu1 contains ValueUnit vu2.
Example
|
|
|
|
|
|
|
|
|
|
|
|
Get the denominators of the value of a ValueUnit.
Example
|
An empty ValueUnit that has no value and no unit, i.e. an empty array with NoUnit.
|
|
|
|
|
|
|
Filter the value of a value unit using a predicate function pred. This function is parameterized on the base value of the value unit.
Example
|
Full Usage:
filterValues fPred
Parameters:
BigRational -> bool
-
The predicate function to use
Returns: ValueUnit -> ValueUnit
|
Filter the values in a ValueUnit using a predicate function pred.
|
|
Parse a string into a ValueUnit
Example
|
Full Usage:
generalSingleValueUnit v n s
Parameters:
RationalX
n : BigRational
s : string
Returns: ValueUnit
|
Create a general 'single' ValueUnit with unit value n general text s and single value v
|
|
|
Full Usage:
generalValueUnit v n s
Parameters:
RationalX[]
n : BigRational
s : string
Returns: ValueUnit
|
Create a general ValueUnit with unit value n general text s and value v
|
|
Get the value and the unit of a ValueUnit as a tuple. Example: get (ValueUnit ([|1N; 2N; 3N|], Mass (KiloGram 1N))) = ([|1N; 2N; 3N|], Mass (KiloGram 1N))
|
|
Get the Value of a ValueUnit vu as the base value
Example
|
|
|
|
|
|
|
|
Get the value of a ValueUnit. Example: getValue (ValueUnit ([|1N; 2N; 3N|], Mass (KiloGram 1N))) = [|1N; 2N; 3N|]
|
Check if Value is > 0
|
|
Check if Value >= 0
|
|
|
|
|
|
|
|
|
|
|
Check whether the unit is a count unit, i.e. belongs to the Count group
|
Checks whether a ValueUnit has an empty value
|
|
|
Check whether a ValueUnit is a single value
|
|
Check if a ValueUnit is a subset of another ValueUnit.
Example
|
Check if Value is zero
|
|
Full Usage:
mapValues fMap
Parameters:
BigRational -> RationalX
-
The function to appy to each individual value
Returns: ValueUnit -> ValueUnit
|
Map the values in a ValueUnit using a function fMap.
|
|
Calculate the maximum value of a ValueUnit that is a maximum exclusive and is a multiple of Increment.
Example
|
|
Calculate the maximum value of a ValueUnit that is a maximum inclusive and is a multiple of Increment.
Example
|
|
|
|
|
|
Calculate the minimum value of a ValueUnit that is a minimum exclusive and is a multiple of Increment.
Example
|
|
Calculate the minimum value of a ValueUnit that is a minimum inclusive and is a multiple of Increment.
Example
|
|
|
|
|
|
|
Get the numerators of the value of a ValueUnit.
Example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Simplify a value unit u such that units are algebraically removed or transformed to count units, where applicable.
Example
|
|
|
|
|
|
|
Check if Value < 0
|
|
Check if Value <= 0
|
|
|
|
|
|
|
|
|
Get the value of a ValueUnit as a base value. For example ValueUnit(1000, mg) -> 1
|
Full Usage:
toDelimitedString isWithUnit prec vu
Parameters:
bool
-
Whether to print the unit
prec : int
-
The precision with which value should be printed
vu : ValueUnit
-
The ValueUnit to print
Returns: string
|
Print a ValueUnit to a string with a given precision delimited by "#" for Value and "|" for Unit
Example
|
Full Usage:
toString hasGroup brf loc verb vu
Parameters:
bool
-
When true, includes the unit group in brackets (e.g., "[Mass]"); when false, omits it
brf : BigRational -> 'a
-
The function to turn a BigRational into a string
loc : Localization
-
The localization to use
verb : Verbal
-
The verbosity to use
vu : ValueUnit
-
The ValueUnit
Returns: string
Type parameters: 'a (requires equality) |
Get the user readable string version of a ValueUnit
Example
|
|
Get the user readable string version in Dutch with verbosity long, value as decimal, and group annotation
|
|
Get the user readable string version in Dutch with verbosity short, value as decimal, and group annotation
|
Full Usage:
toStringDecimalDutchShortWithPrec prec vu
Parameters:
int
-
The precision
vu : ValueUnit
-
The ValueUnit
Returns: string
|
Get the user readable string version in Dutch with verbosity short, value as decimal with a fixed precision, and without group annotation. A value beyond the range of a decimal is printed as its fraction.
Example
|
|
Get the user readable string version in English with verbosity long, value as decimal, and group annotation
|
|
Get the user readable string version in English with verbosity short, value as decimal, and group annotation
|
|
Get the user readable string version in English with verbosity short, value as decimal, without group annotation
|
|
Get the user readable string version in Dutch with verbosity long and group annotation
|
|
Get the user readable string version in Dutch with verbosity short and group annotation
|
|
Get the user readable string version in English with verbosity long and group annotation
|
|
Get the user readable string version in English with verbosity short and group annotation
|
|
|
|
Get the value of a ValueUnit as a unit value ValueUnit(1, mg) -> 1000
|
Full Usage:
unitToReadableDutchString u
Parameters:
Unit
-
The unit to convert to string
Returns: string
|
Get the user readable string version of a unit in Dutch short format without unit group annotation (i.e., without brackets)
Example
|
Full Usage:
unitToReadableDutchStringWithWrappers vw uw u
Parameters:
string
-
A wrapper around a unit value > 1
uw : string
-
A wrapper around a unit
u : Unit
-
The unit to convert to string
Returns: string
|
Get the user readable string version of a unit in Dutch short format without unit group annotation (i.e., without brackets) and a wrapper w
Example
|
Full Usage:
validate fValid errMsg vu
Parameters:
BigRational[] -> bool
-
The validator function
errMsg : 'a
-
The error message
vu : ValueUnit
-
The ValueUnit
Returns: Result<ValueUnit, 'a>
Result.Ok vu if the values are valid, Result.Error errMsg otherwise
Type parameters: 'a |
Validates the values of Value for a ValueUnit.
|
|
Get the count of elements in a Value
Example
|
|
|
|
|
|
|
|
|
GenPRES