omdl  v0.9.5
OpenSCAD Mechanical Design Library
Iterable Tests

Tests to differentiate iterable data types. More...

+ Collaboration diagram for Iterable Tests:

Files

file  iterable_test.scad
 Iterable data type tests.
 

Functions

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 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, c=0)
 Test if all elements of an iterable value are lists. More...
 
function all_strings (v, c=0)
 Test if all elements of an iterable value are strings. More...
 
function all_numbers (v, c=0)
 Test if all elements of an iterable value are numbers. More...
 
function all_len (v, l, c=0)
 Test if all elements of an iterable value are iterable with a fixed length. More...
 

Detailed Description

Tests to differentiate iterable data types.

Requires:
include <omdl-base.scad>;

Validation Summary

filegroupscriptresultsno testskippedpassedfailedwarning
datatypes/iterable_test.scadIterable TestsScriptResults0046000

No Failures

See complete validation results.

Function Documentation

◆ all_defined()

function all_defined ( )

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.
+ Here is the caller graph for this function:

◆ all_equal()

function all_equal ( ,
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.
+ Here is the caller graph for this function:

◆ all_iterables()

function all_iterables ( )

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_len()

function all_len ( ,
,
= 0 
)

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.

◆ all_lists()

function all_lists ( ,
= 0 
)

Test if all elements of an iterable value are lists.

Parameters
v<iterable> An iterable data type value.
c<integer> (internal) Count of passing comparisons.
Returns
<boolean> true when all elements of v are lists and false otherwise. Returns true when v is a single iterable list.
Note
The parameter c is an internal variable used to count the number of successful comparisons performed while traversing v. This parameter should not be initialized under normal circumstances.

◆ all_numbers()

function all_numbers ( ,
= 0 
)

Test if all elements of an iterable value are numbers.

Parameters
v<iterable> An iterable data type value.
c<integer> (internal) Count of passing comparisons.
Returns
<boolean> true when all elements of v are numerical values and false otherwise. Returns true when v is a single numerical value.
Note
The parameter c is an internal variable used to count the number of successful comparisons performed while traversing v. This parameter should not be initialized under normal circumstances.
+ Here is the caller graph for this function:

◆ all_oneof()

function all_oneof ( ,
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_scalars()

function all_scalars ( )

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_strings()

function all_strings ( ,
= 0 
)

Test if all elements of an iterable value are strings.

Parameters
v<iterable> An iterable data type value.
c<integer> (internal) Count of passing comparisons.
Returns
<boolean> true when all elements of v are strings and false otherwise. Returns true when v is a single string.
Note
The parameter c is an internal variable used to count the number of successful comparisons performed while traversing v. This parameter should not be initialized under normal circumstances.
+ Here is the caller graph for this function:

◆ any_defined()

function any_defined ( )

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_equal()

function any_equal ( ,
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.

◆ any_undefined()

function any_undefined ( )

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.
+ Here is the caller graph for this function:

◆ is_empty()

function 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.
+ Here is the caller graph for this function:

◆ is_iterable()

function is_iterable ( )

Test if a value has multiple parts and is iterable.

Parameters
v<value> A value.
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.