Tests to differentiate iterable data types.
More...
|
| function | is_iterable (v) |
| | Test if a value has multiple parts and is iterable. More...
|
| |
| function | is_empty (v) |
| | Test if an iterable value is empty. More...
|
| |
| function | all_equal (v, cv) |
| | Test if all elements of an iterable value equal a comparison value. More...
|
| |
| function | any_equal (v, cv) |
| | Test if any element of an iterable value equal a comparison value. More...
|
| |
| function | is_oneof (v, cv) |
| | Test if a value equals one of the comparison values. More...
|
| |
| function | all_oneof (v, cv) |
| | Test if all elements of an iterable value equal one of the comparison values. More...
|
| |
| function | all_defined (v) |
| | Test if no element of an iterable value has an undefined value. More...
|
| |
| function | any_defined (v) |
| | Test if at least one element of an iterable value has a defined value. More...
|
| |
| function | any_undefined (v) |
| | Test if at least one element of an iterable value has an undefined value. More...
|
| |
| function | all_scalars (v) |
| | Test if all elements of an iterable value are scalar values. More...
|
| |
| function | all_iterables (v) |
| | Test if all elements of an iterable value are iterable. More...
|
| |
| function | all_lists (v) |
| | Test if all elements of an iterable value are lists. More...
|
| |
| function | all_strings (v) |
| | Test if all elements of an iterable value are strings. More...
|
| |
| function | all_numbers (v) |
| | Test if all elements of an iterable value are numbers. More...
|
| |
| function | all_len (v, l) |
| | Test if all elements of an iterable value are iterable with a fixed length. More...
|
| |
Tests to differentiate iterable data types.
Validation Summary
No Failures
See complete validation results.
- Conventions
- The primary parameter is always
v (the iterable value under test).
- The comparison value is always
cv.
- All
all_* functions return true vacuously for an empty v, except all_lists(), all_strings(), all_numbers(), and all_len(), which require at least one matching element (c > 0) and return false for an empty iterable.
- The parameter
c in all_lists(), all_strings(), all_numbers(), and all_len() is an internal recursion counter. It must not be initialised by callers; doing so produces incorrect results.
- When
v is a non-iterable scalar, functions return the result of applying the predicate directly to v rather than returning undef.
◆ is_iterable()
| function is_iterable |
( |
v |
| ) |
|
Test if a value has multiple parts and is iterable.
- Parameters
-
- Returns
- <boolean> true when the value is an iterable multi-part value and false otherwise.
| input value | function return |
| number | false |
| boolean | false |
| string | true |
| list | true |
| range | false |
| undef | false |
| inf | false |
| nan | false |
- Note
- The empty list and empty string return true.
◆ is_empty()
Test if an iterable value is empty.
- Parameters
-
| v | <iterable> An iterable data type value. |
- Returns
- <boolean> true when the iterable value has zero elements and false otherwise. Returns true when
v is not an iterable value.
◆ all_equal()
| function all_equal |
( |
v |
, |
|
|
cv |
|
|
) |
| |
Test if all elements of an iterable value equal a comparison value.
- Parameters
-
| v | <iterable> An iterable data type value. |
| cv | <value> A comparison value. |
- Returns
- <boolean> true when all elements of
v equal the value cv and false otherwise. Returns true when v is empty.
◆ any_equal()
| function any_equal |
( |
v |
, |
|
|
cv |
|
|
) |
| |
Test if any element of an iterable value equal a comparison value.
- Parameters
-
| v | <iterable> An iterable data type value. |
| cv | <value> A comparison value. |
- Returns
- <boolean> true when any element of
v equals the value cv and false otherwise. Returns false when v is empty.
◆ is_oneof()
| function is_oneof |
( |
v |
, |
|
|
cv |
|
|
) |
| |
Test if a value equals one of the comparison values.
- Parameters
-
| v | <value> A value. |
| cv | <iterable> An iterable of one or more comparison values. |
- Returns
- <boolean> true when
v equals any one of the values in cv and false otherwise.
◆ all_oneof()
| function all_oneof |
( |
v |
, |
|
|
cv |
|
|
) |
| |
Test if all elements of an iterable value equal one of the comparison values.
- Parameters
-
| v | <iterable> An iterable data type value. |
| cv | <value> An iterable of one more more comparison values. |
- Returns
- <boolean> true when all elements of
v equal one of the values in cv and false otherwise. Returns true when v is empty.
When v is a string, cv must also be a string.
◆ all_defined()
| function all_defined |
( |
v |
| ) |
|
Test if no element of an iterable value has an undefined value.
- Parameters
-
| v | <iterable> An iterable data type value. |
- Returns
- <boolean> true when no element of
v has its value equal to undef and false otherwise. Returns true when the iterable v is empty.
◆ any_defined()
| function any_defined |
( |
v |
| ) |
|
Test if at least one element of an iterable value has a defined value.
- Parameters
-
| v | <iterable> An iterable data type value. |
- Returns
- <boolean> true when any element of
v has a defined value and false otherwise. Returns false when v is empty.
◆ any_undefined()
| function any_undefined |
( |
v |
| ) |
|
Test if at least one element of an iterable value has an undefined value.
- Parameters
-
| v | <iterable> An iterable data type value. |
- Returns
- <boolean> true when any element of
v has an undefined value and false otherwise. Returns false when v is empty.
◆ all_scalars()
| function all_scalars |
( |
v |
| ) |
|
Test if all elements of an iterable value are scalar values.
- Parameters
-
| v | <iterable> An iterable data type value. |
- Returns
- <boolean> true when all elements of
v are scalar values and false otherwise. Returns true when v is a single scalar value and true when the v is an empty, or undefined.
◆ all_iterables()
| function all_iterables |
( |
v |
| ) |
|
Test if all elements of an iterable value are iterable.
- Parameters
-
| v | <iterable> An iterable data type value. |
- Returns
- <boolean> true when all elements of
v are iterable and false otherwise. Returns true when v is a single iterable value and returns true when v is a empty. Returns false when v is undefined.
◆ all_lists()
Test if all elements of an iterable value are lists.
- Parameters
-
| v | <iterable> An iterable data type value. |
- Returns
- <boolean> true when all elements of
v are lists and false otherwise. Returns true when v is a single iterable list.
◆ all_strings()
| function all_strings |
( |
v |
| ) |
|
Test if all elements of an iterable value are strings.
- Parameters
-
| v | <iterable> An iterable data type value. |
- Returns
- <boolean> true when all elements of
v are strings and false otherwise. Returns true when v is a single string.
◆ all_numbers()
| function all_numbers |
( |
v |
| ) |
|
Test if all elements of an iterable value are numbers.
- Parameters
-
| v | <iterable> An iterable data type value. |
- Returns
- <boolean> true when all elements of
v are numerical values and false otherwise. Returns true when v is a single numerical value.
◆ all_len()
| function all_len |
( |
v |
, |
|
|
l |
|
|
) |
| |
Test if all elements of an iterable value are iterable with a fixed length.
- Parameters
-
| v | <iterable> An iterable data type value. |
| l | <integer> The required length of each value. |
- Returns
- <boolean> true when all elements of
v are iterable values with lengths equal to l and false otherwise.