Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation for math, comparisons, and functions #73

Merged
merged 9 commits into from
Mar 6, 2024
39 changes: 20 additions & 19 deletions docs/arcaflow/workflows/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,24 @@ available from operators.

Functions:

| function definition | return type | description |
|-------------------------------|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `intToFloat(integer)` | float | Converts an integer value into the equivalent floating point value. |
| `floatToInt(float)` | integer | Converts a floating point value into an integer value by discarding the fraction, rounding toward zero to the nearest integer.<br>Special cases:<br>&nbsp; +Inf yields the maximum 64-bit integer (9223372036854775807)<br>&nbsp; -Inf and NaN yield the minimum 64-bit integer (-9223372036854775808)\n\n"<br><br>For example, `5.5` yields `5`, and `-1.9` yields `-1`" |
| `intToString(integer)` | string | Returns a string containing the base-10 representation of the input.<br><br>For example, an input of `55` yields `"55"` |
| `floatToString(float)` | string | Returns a string containing the base-10 representation of the input.<br><br>For example, an input of `5000.5` yields `"5000.5"` |
| `boolToString(boolean)` | string | Returns `"true"` for `true`, and `"false"` for `false`. |
| `stringToInt(string)` | integer | Interprets the string as a base-10 integer. Returns an error if the input is not a valid integer. |
| `stringToFloat(string)` | float | Converts the input string to a double-precision floating-point number.<br><br>Accepts floating-point numbers as defined by the [Go syntax for floating point literals](https://go.dev/ref/spec#Floating-point_literals). If the input is well-formed and near a valid floating-point number, returns the nearest floating-point number rounded using IEEE754 unbiased rounding.<br>Returns an error when an invalid input is received. |
| `stringToBool(string)` | boolean | Interprets the input as a boolean.<br>Accepts `"1"`, `"t"`, and `"true"` as `true` and `"0"`, `"f"`, and `"false"` as `false` (case is not significant).<br>Returns an error for any other input. |
| `ceil(float)` | float | Returns the least integer value greater than or equal to the input.<br><br>For example `ceil(1.5)` yields `2.0`, and `ceil(-1.5)` yields `-1.0`<br>Special cases are:<br>&nbsp; ceil(±0.0) = ±0.0<br>&nbsp; ceil(±Inf) = ±Inf<br>&nbsp; ceil(NaN) = NaN |
| `floor(float)` | float | Returns the greatest integer value less than or equal to the input.<br><br>For example `floor(1.5)` yields `1.0`, and `floor(-1.5)` yields `-2.0`<br>Special cases are:<br>&nbsp; floor(±0.0) = ±0.0<br>&nbsp; floor(±Inf) = ±Inf<br>&nbsp; floor(NaN) = NaN |
| `round(float)` | float | Returns the nearest integer to the input, rounding half away from zero.<br><br>For example `round(1.5)` yields `2.0`, and `round(-1.5)` yields `-2.0`<br>Special cases are:<br>&nbsp; round(±0.0) = ±0.0<br>&nbsp; round(±Inf) = ±Inf<br>&nbsp; round(NaN) = NaN |
| `abs(float)` | float | Returns the absolute value of the input.<br>Special cases are:<br>&nbsp; abs(±Inf) = +Inf<br>&nbsp; abs(NaN) = NaN |
| `toLower(string)` | string | Returns the input with Unicode letters mapped to their lower case. |
| `toUpper(string)` | string | Returns the input with Unicode letters mapped to their upper case. |
| `splitString(string, string)` | list[string] | Returns a list of the substrings which appear between instances of the specified separator; the separator instances are not included in the resulting list elements; adjacent occurrences of separator instances as well as instances appearing at the beginning or ending of the input will produce empty string list elements.<br>&nbsp; Param 1: The string to split.<br>&nbsp; Param 2: The separator. |
| function definition | return type | description |
|--------------------------------------------------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `intToFloat(integer)` | float | Converts an integer value into the equivalent floating point value. |
| `floatToInt(float)` | integer | Converts a floating point value into an integer value by discarding the fraction, rounding toward zero to the nearest integer.<br>Special cases:<br>&nbsp; +Inf yields the maximum 64-bit integer (9223372036854775807)<br>&nbsp; -Inf and NaN yield the minimum 64-bit integer (-9223372036854775808)\n\n"<br><br>For example, `5.5` yields `5`, and `-1.9` yields `-1`" |
mfleader marked this conversation as resolved.
Show resolved Hide resolved
| `intToString(integer)` | string | Returns a string containing the base-10 representation of the input.<br><br>For example, an input of `55` yields `"55"` |
| `floatToString(float)` | string | Returns a string containing the base-10 representation of the input.<br><br>For example, an input of `5000.5` yields `"5000.5"` |
| `floatToFormattedString(float, string, integer)` | string | Returns a string containing the input formatted according to the specified formatting directive and precision.<br>&nbsp; Param 1: the floating point value to convert<br>&nbsp; Param 2: the format specifier: 'e', 'E', 'f', 'g', 'G'<br>&nbsp; Param 3: the number of digits<br><br>Specifying -1 for the precision will produce the minimum number of digits required to represent the value exactly.<br>(See the [Go runtime documentation](https://pkg.go.dev/[email protected]#FormatFloat) for details.) |
dbutenhof marked this conversation as resolved.
Show resolved Hide resolved
| `boolToString(boolean)` | string | Returns `"true"` for `true`, and `"false"` for `false`. |
| `stringToInt(string)` | integer | Interprets the string as a base-10 integer. Returns an error if the input is not a valid integer. |
| `stringToFloat(string)` | float | Converts the input string to a double-precision floating-point number.<br><br>Accepts floating-point numbers as defined by the [Go syntax for floating point literals](https://go.dev/ref/spec#Floating-point_literals). If the input is well-formed and near a valid floating-point number, returns the nearest floating-point number rounded using IEEE754 unbiased rounding.<br>Returns an error when an invalid input is received. |
| `stringToBool(string)` | boolean | Interprets the input as a boolean.<br>Accepts `"1"`, `"t"`, and `"true"` as `true` and `"0"`, `"f"`, and `"false"` as `false` (case is not significant).<br>Returns an error for any other input. |
| `ceil(float)` | float | Returns the least integer value greater than or equal to the input.<br><br>For example `ceil(1.5)` yields `2.0`, and `ceil(-1.5)` yields `-1.0`<br>Special cases are:<br>&nbsp; ceil(±0.0) = ±0.0<br>&nbsp; ceil(±Inf) = ±Inf<br>&nbsp; ceil(NaN) = NaN |
| `floor(float)` | float | Returns the greatest integer value less than or equal to the input.<br><br>For example `floor(1.5)` yields `1.0`, and `floor(-1.5)` yields `-2.0`<br>Special cases are:<br>&nbsp; floor(±0.0) = ±0.0<br>&nbsp; floor(±Inf) = ±Inf<br>&nbsp; floor(NaN) = NaN |
| `round(float)` | float | Returns the nearest integer to the input, rounding half away from zero.<br><br>For example `round(1.5)` yields `2.0`, and `round(-1.5)` yields `-2.0`<br>Special cases are:<br>&nbsp; round(±0.0) = ±0.0<br>&nbsp; round(±Inf) = ±Inf<br>&nbsp; round(NaN) = NaN |
| `abs(float)` | float | Returns the absolute value of the input.<br>Special cases are:<br>&nbsp; abs(±Inf) = +Inf<br>&nbsp; abs(NaN) = NaN |
| `toLower(string)` | string | Returns the input with Unicode letters mapped to their lower case. |
| `toUpper(string)` | string | Returns the input with Unicode letters mapped to their upper case. |
| `splitString(string, string)` | list[string] | Returns a list of the substrings which appear between instances of the specified separator; the separator instances are not included in the resulting list elements; adjacent occurrences of separator instances as well as instances appearing at the beginning or ending of the input will produce empty string list elements.<br>&nbsp; Param 1: The string to split.<br>&nbsp; Param 2: The separator. |

A function is used in an expression by referencing its name followed by a comma-separated list of zero or more argument
expressions enclosed in parentheses.
Expand Down Expand Up @@ -419,7 +420,7 @@ Unary operations are operations that have one input. The operator is applied to

| Operator | Description |
|----------|-------------------------------------------|
| - | [Negation](#Negation) |
| - | [Negation](#negation) |
dbutenhof marked this conversation as resolved.
Show resolved Hide resolved
| ! | [Logical complement](#logical-complement) |

### Negation
Expand Down Expand Up @@ -473,7 +474,7 @@ Order (highest to lowest):

## Other information

More information on the expression language is available in the [development guide](/arcaflow/contributing/expressions).
More information on the expression language is available in the [development guide](/docs/arcaflow/contributing/expressions.md).
dbutenhof marked this conversation as resolved.
Show resolved Hide resolved

## Examples

Expand Down
Loading