omdl  v0.9.5
OpenSCAD Mechanical Design Library
Index sequence generation

The data type index refers to a specified sequence of list element indexes. A list index sequence may be specified in one of the following forms.

value / form description
true All index positions of the list [0:size-1]
false No index positions
"all" All index positions of the list [0:size-1]
"none" No index positions
"rands" Random index selection of the list [0:size-1]
"even" The even index of the list [0:size-1]
"odd" The odd index of the list [0:size-1]
<integer> The single position given by an <integer>
<range> The range of positions given by a <range>
<integer-list> The list of positions give in <integer-list>

The function index_gen() can be used to convert a value of this data type into a sequence of list element indexes.

Example

// list
l1 = [a,b,c,d,e,f]
// index sequence
index_gen(l1) = [0,1,2,3,4,5]
index_gen(l1, "rands") = [0,2,5]
function index_gen(l, s=true, rs)
Create a element selection index list for a given list of values.