76 ) = let(i =
first( search( [ri], r, 1, 0 ) ) )
105 ) = let(i =
first( search( [ci], c, 1, 0 ) ) )
276 ) = (
is_defined(r) && is_undef(c) ) ? len( r )
278 : len( r ) * len( c );
359 str (
"table column 0 should be 'id'")
367 if ( col_cnt != len ( r_iter ) )
371 ", id=[",
first(r_iter),
"]",
372 ", has incorrect column count=[", len ( r_iter ),
"]"
380 if ( len(
first(search([
first(c_iter)], c, 0, 0))) > 1 )
381 str(
"repeating column identifier [",
first(c_iter),
"]")
388 if ( len(
first(search([
first(r_iter)], r, 0, 0))) > 1 )
389 str(
"repeating row identifier [",
first(r_iter),
"]")
392 concat(ec1, ec2, ec3, ec4);
416 if (verbose)
log_info(
"begin table check");
421 log_warn (
"table column 0 should be 'id'");
425 if (verbose)
log_info (
"row identifier found at column zero.");
429 if (verbose)
log_info (
"checking row column counts.");
435 col_cnt == len ( r_iter ),
439 ", id=[",
first(r_iter),
"]",
440 ", has incorrect column count=[", len ( r_iter ),
"]",
441 ", expecting=[", col_cnt,
"]"
447 if (verbose)
log_info (
"checking for repeat column identifiers.");
449 if ( len(
first(search([
first(c_iter)], c, 0, 0))) > 1 )
450 log_warn ( str(
"repeating column identifier [",
first(c_iter),
"]") );
453 if (verbose)
log_info (
"checking for repeat row identifiers.");
455 if ( len(
first(search([
first(r_iter)], r, 0, 0))) > 1 )
456 log_warn ( str(
"repeating row identifier [",
first(r_iter),
"]") );
498 maxr0 = max( [
for (r_iter = r) len(
first(r_iter) )] ) + 1;
499 maxc0 = max( [
for (c_iter = c) len(
first(c_iter) )] ) + 1;
500 maxc1 = max( [
for (c_iter = c) len( c_iter[1] )] ) + 1;
529 "(", c_iter[1],
")", chr(
consts(maxc1-len(c_iter[1]), 32)),
601 function qri(ri) = (ri ==
"ri") ? ri : (vri ==
true) ? ri : str(
"\"", ri,
"\"");
602 function qci(ci) = (ci ==
"ci") ? ci : (vci ==
true) ? ci : str(
"\"", ci,
"\"");
607 (ri ==
"ri")?
"":(append?str(
"_", ri):
""),
608 (ci ==
"ci")?
"":(append?str(
"_", ci):
"")
615 echo(
"Checking table...");
629 "// table value getter function",
630 (ri ==
"ri")?
"":str(
", constant row ri=", qri(ri)),
631 (ci ==
"ci")?
"":str(
", constant column ci=", qci(ci)),
634 if (comment > 0) echo (str(gct));
641 "function ", gfn(name),
643 (ri ==
"ri")?
"ri":
"",
644 (ri ==
"ri") && (ci ==
"ci")?
", ":
"",
645 (ci ==
"ci")?
"ci":
"",
646 ") = table_get_value (r=", tr,
660 if ( (ri !=
"ri") && (ci ==
"ci") )
668 gct = str(
"// get ci=", qci(i),
" (",
second(cic),
") & ri=", qri(ri),
".");
669 if (comment == 1) echo (str(gct));
675 (append?str(ri,
"_"):
""), i,
" = ",
676 gfn(name),
"(ci=", qci(i),
");",
677 (comment == 2)?str(
"\t", gct):
""
684 echo( str(
"row ri=", qri(ri),
" does not exist in table." ) );
689 else if ( (ri ==
"ri") && (ci !=
"ci") )
695 gct = str(
"// get ri=", qri(i),
" & ci=", qci(ci),
".");
696 if (comment == 1) echo (str(gct));
702 i, (append?str(
"_", ci):
""),
" = ",
703 gfn(name),
"(ri=", qri(i),
");",
704 (comment == 2)?str(
"\t", gct):
""
711 echo( str(
"column ci=", qci(ci),
" does not exist in table." ) );
716 else if ( (ri !=
"ri") && (ci !=
"ci") )
718 if ( vri || vci ||
table_exists( r=r, c=c, ri=ri, ci=ci ) )
719 { gct = str(
"// get ri=", qri(ri),
" & ci=", qci(ci),
".");
720 if (comment == 1) echo (str(gct));
727 gfn(name),
"(ri=", qri(ri),
", ci=", qci(ci),
");",
728 (comment == 2)?str(
"\t", gct):
""
738 "row ri=", qri(ri),
", column ci=", qci(ci),
739 " does not exist in table."
747 echo (
"Table has errors." );
797 heading_text =
false,
817 (heading_id && heading_text) ? str(
second(c_iter),
" (",
first(c_iter),
")")
818 : (heading_id ) ?
first(c_iter)
819 : ( heading_text) ?
second(c_iter)
823 if ( heading_id || heading_text )
842 for ( c_iter =
tailn(c, n=1) )
module log_warn(m)
Output warning message to console.
module log_echo(m)
Output message to console.
module log_info(m)
Output information message to console.
empty_str
<string> A string with no characters (the empty string).
empty_lst
<list> A list with no values (the empty list).
function headn(v, n=1)
Return a list containing all but the last n elements of an iterable value.
function last(v)
Return the last element of an iterable value.
function second(v)
Return the second element of an iterable value.
function first(v)
Return the first element of an iterable value.
function tailn(v, n=1)
Return a list containing all but the first n elements of an iterable value.
function consts(l, v, u=false)
Create a list of constant or incrementing elements.
function strl(v)
Convert a list of values to a concatenated string.
function strl_html(v, b, p, a, f, d=false)
Convert a list of values to a concatenated HTML-formatted string.
function sum(v, i1, i2)
Compute the sum of a list of numbers.
function select_e(v, i, f, l)
Select each element at an index position of a list of iterable values.
function is_defined(v)
Test if a value is defined.
function is_number(v)
Test if a value is a number.
function ctable_exists(t, ri, ci)
Test the existence of a table row identifier, table column identifier, or both.
function table_get_size(r, c)
Get the size of a table.
function table_get_copy(r, c, rs, cs)
Create a new matrix from select rows and columns of a table.
function table_exists(r, c, ri, ci)
Test the existence of a table row identifier, table column identifier, or both.
module table_dump_getters(r, c, tr="table_rows", tc="table_cols", ri="ri", ci="ci", vri=false, vci=false, name="get_helper", append=false, comment=0, verbose=false)
Dump table getter functions to the console.
function table_get_columns(r, c, ci)
Form a list of a select column across all table rows.
function table_get_row(r, ri)
Get the table row that matches a table row identifier.
function table_get_row_index(r, ri)
Get the table row index that matches a table row identifier.
function table_get_column_index(c, ci)
Get the table column index that matches a table column identifier.
module table_check(r, c, verbose=false)
Perform basic format checks on a table and output errors to console.
module table_write(r, c, rs, cs, number=false, heading_id=true, heading_text=false, fs="^", thn="idx", index_tags=empty_lst, row_id_tags=["b"], value_tags=empty_lst)
Write formatted map entries to the console.
function table_get_sum(r, c, rs, cs)
Sum select rows and columns of a table.
function table_get_row_ids(r)
Form a list of all table row identifiers.
function ctable_get_size(t)
Get the size of a table.
function table_get_column_ids(c)
Form a list of all table column identifiers.
module table_dump(r, c, rs, cs, number=true)
Dump a table to the console.
function table_get(r, c, ri, ci)
Get a row, a column, or a specific cell value from a table.
function table_errors(r, c)
Perform basic format checks on a table and return errors.
function ctable_errors(t)
Perform basic format checks on a table and return errors.
function ctable_get(t, ri, ci)
Get a row, a column, or a specific cell value from a table.
function table_get_column(c, ci)
Get the table column that matches a table column identifier.
function table_get_value(r, c, ri, ci)
Get the table cell value for a specified row and column identifier.