34 include <primitives.scad>;
72 ) =
first( search( [row_id], rows, 1, 0 ) );
104 ) =
first( search( [col_id], cols, 1, 0 ) );
235 : len( rows ) * len( cols );
260 if (verbose)
log_info(
"begin table check");
265 log_warn (
"table column 0 should be 'id'");
269 if (verbose)
log_info (
"row identifier found at column zero.");
273 if (verbose)
log_info (
"checking row column counts.");
277 if ( col_cnt != len ( r ) )
283 ", id=[",
first(r),
"]",
284 ", has incorrect column count=[", len ( r ),
"]"
291 if (verbose)
log_info (
"checking for repeat column identifiers.");
293 if ( len(
first(search([
first(c)], cols, 0, 0))) > 1 )
294 log_warn ( str(
"repeating column identifier [",
first(c),
"]") );
297 if (verbose)
log_info (
"checking for repeat row identifiers.");
299 if ( len(
first(search([
first(r)], rows, 0, 0))) > 1 )
300 log_warn ( str(
"repeating row identifier [",
first(r),
"]") );
345 maxr0 = max( [
for (r = rows) len(
first(r) )] ) + 1;
346 maxc0 = max( [
for (c = cols) len(
first(c) )] ) + 1;
347 maxc1 = max( [
for (c = cols) len( c[1] )] ) + 1;
375 "(", c[1],
")", chr(
consts(maxc1-len(c[1]), 32)),
module log_error(m)
Output error message to console.
function table_size(rows, cols)
Get the size of a table.
module table_check(rows, cols, verbose=false)
Perform some basic validation/checks on a table.
function first(v)
Return the first element of an iterable value.
module log_info(m)
Output information message to console.
module log_echo(m)
Output message to console.
function table_get_col_idx(cols, col_id)
Get the index for a table column identifier.
function sum(v, i1, i2)
Compute the sum of a vector of numbers.
function not_defined(v)
Test if a value is not defined.
function table_get_row_idx(rows, row_id)
Get the index for a table row identifier.
function is_empty(v)
Test if an iterable value is empty.
function table_exists(rows, cols, row_id, col_id)
Test the existence of a table row and column identifier.
function table_get_row(rows, row_id)
Get the row for a table row identifier.
function table_sum(rows, cols, rows_sel, cols_sel)
Sum select rows and columns of a table.
module table_dump(rows, cols, rows_sel, cols_sel, number=true)
Dump a table to the console.
function eselect(v, f=true, l=false, i)
Select an element from each iterable value.
function table_copy(rows, cols, rows_sel, cols_sel)
Create a copy of select rows and columns of a table.
module log_warn(m)
Output warning message to console.
function table_get_row_cols(rows, cols, col_id)
Form a vector from the specified column of each table row.
function table_get_row_ids(rows)
Form a vector of each table row identifier.
function table_get(rows, cols, row_id, col_id)
Get the value for a table row and column identifier.
function is_defined(v)
Test if a value is defined.
function consts(l, v)
Create a vector of constant elements.
function table_get_col(cols, col_id)
Get the column for a table column identifier.