Tests to differentiate scalar data types.
More...
Tests to differentiate scalar data types.
Validation Summary
No Failures
See complete validation results.
- Conventions
- The primary parameter is always
v (the value under test).
- All functions whose name begins with
is_ return <boolean>.
empty_str and empty_lst are treated as iterable, not scalar.
- is_integer() and is_decimal() are mutually exclusive; a value cannot satisfy both. is_decimal() requires (v % 1) != 0 (not > 0) so that negative decimals such as -1.5 are correctly identified.
- is_between() uses inclusive bounds at both ends.
- The parameters
l and u in is_between() denote the lower and upper bounds respectively. They are unrelated to l = list-length used in other groups; prefer vmin / vmax in future revisions.
◆ is_scalar()
Test if a value is a single non-iterable value.
- Parameters
-
- Returns
- <boolean> true when the value is a single non-iterable value and false otherwise.
| input value | function return |
| number | true |
| boolean | true |
| string | false |
| list | false |
| range | true |
| undef | true |
| inf | true |
| nan | true |
- Note
- The empty list and empty string return true.
◆ is_defined()
| function is_defined |
( |
v |
| ) |
|
Test if a value is defined.
- Parameters
-
- Returns
- <boolean> true when the value is defined and false otherwise.
- Note
- Starting with version 2019.05, this function is now provided directly by OpenSCAD via a built-in type test function
is_undef().
◆ is_nan()
Test if a numerical value is 'nan' (not a number).
- Parameters
-
| v | <value> A numerical value. |
- Returns
- <boolean> true when the value is determined to be nan (Not A Number) and false otherwise.
◆ is_inf()
Test if a numerical value is infinite.
- Parameters
-
| v | <value> A numerical value. |
- Returns
- <boolean> true when the value is determined to be inf (greater than the largest OpenSCAD representable number) and false otherwise.
◆ is_number()
Test if a value is a number.
- Parameters
-
- Returns
- <boolean> true when the value is a number and false otherwise.
- Note
- Starting with version 2019.05, this function is now provided directly by OpenSCAD via a built-in type test function
is_num().
◆ is_integer()
| function is_integer |
( |
v |
| ) |
|
Test if a value is an integer.
- Parameters
-
- Returns
- <boolean> true when the value is an integer and false otherwise.
◆ is_decimal()
| function is_decimal |
( |
v |
| ) |
|
Test if a value is a decimal.
- Parameters
-
- Returns
- <boolean> true when the value is a decimal and false otherwise.
◆ is_range()
Test if a value is a range definition.
- Parameters
-
- Returns
- <boolean> true when the value is a range definition and false otherwise.
- Note
- A range is determined to be a value which does not fit in any other category. Specifically, It is a value that is not {undef, nan or inf}, and is neither of {list, number, bool, or string}.
◆ is_even()
Test if a numerical value is even.
- Parameters
-
| v | <value> A numerical value. |
- Returns
- <boolean> true when the value is determined to be an even integer and false otherwise (The value may be positive or negative).
◆ is_odd()
Test if a numerical value is odd.
- Parameters
-
| v | <value> A numerical value. |
- Returns
- <boolean> true when the value is determined to be an odd integer and false otherwise (The value may be positive or negative).
◆ is_between()
| function is_between |
( |
v |
, |
|
|
l |
, |
|
|
u |
|
|
) |
| |
Test if a numerical value is between an upper and lower bounds.
- Parameters
-
| v | <number> A numerical value. |
| l | <number> The minimum value. |
| u | <number> The maximum value. |
- Returns
- <boolean> true when the value is equal to or between the upper and lower bounds and false otherwise. Returns false when either of
v, l, or u is not a number.