omdl
v0.6.1
OpenSCAD Mechanical Design Library
|
List data type identification. More...
Files | |
file | datatypes-base.scad |
Include file wrapper of data types base primitives. | |
Functions | |
function | n_almost_equal (v1, v2, p=6) |
Test if all elements of two lists of numbers are sufficiently equal. More... | |
function | almost_equal (v1, v2, p=6) |
Test if all numerical elements of two lists of values are sufficiently equal. More... | |
function | compare (v1, v2, s=true) |
Order to lists of arbitrary values. More... | |
List data type identification.
See validation results.
function almost_equal | ( | v1 | , |
v2 | , | ||
p | = 6 |
||
) |
Test if all numerical elements of two lists of values are sufficiently equal.
v1 | <list> A list of values 1. |
v2 | <list> A list of values 2. |
p | <number> The numerical precision. |
The 'distance' between two numbers must be less than pow(10,-p) to be considered almost equal. All numerical comparisons are performed to the specified precision. All non-numeric comparisons test for equality.
function compare | ( | v1 | , |
v2 | , | ||
s | = true |
||
) |
Order to lists of arbitrary values.
v1 | <list> A list of values 1. |
v2 | <list> A list of values 2. |
s | <boolean> Order ranges by their numerical sum. |
(v2 < v1)
, +1 when (v2 > v1)
, and 0 when (v2 == v1)
.The following table summarizes how values are ordered.
order | type | s | intra-type ordering |
---|---|---|---|
1 | undef | (singular) | |
2 | number | numerical comparison | |
3 | boolean | false < true | |
4 | string | lexical comparison | |
5 | list | lengths then element-wise comparison | |
6 | range | true | compare sum of range elements |
6 | range | false | lengths then element-wise comparison |
function n_almost_equal | ( | v1 | , |
v2 | , | ||
p | = 6 |
||
) |
Test if all elements of two lists of numbers are sufficiently equal.
v1 | <number-list> A list of numbers 1. |
v2 | <number-list> A list of numbers 2. |
p | <number> The numerical precision. |
v1
and v2
is less than d
and false otherwise. Returns false when either list contains a non-numerica values, or when the lists are not of the same length.The 'distance' between two numbers must be less than pow(10,-p) to be considered almost equal.