126 ) = let(i =
first( search( [ri], r, 1, 0 ) ) )
142 assert( row_check,
strl([
"table row missing [", ri,
"]."]) )
157 ) = let(i =
first( search( [ci], c, 1, 0 ) ) )
173 assert( column_check,
strl(["table column missing [", ci, "]."]) )
194 assert( row_check,
strl(["table row missing [", ri, "]."]) )
195 assert( column_check,
strl(["table column missing [", ci, "]."]) )
213 assert( column_check,
strl(["table column missing [", ci, "]."]) )
337 ) = (
is_defined(r) && is_undef(c) ) ? len( r )
339 : len( r ) * len( c );
420 str ("table column 0 should be '
id'")
428 if ( col_cnt != len ( r_iter ) )
432 ",
id=[",
first(r_iter), "]",
433 ", has incorrect column
count=[", len ( r_iter ),"]"
441 if ( len(
first(search([
first(c_iter)], c, 0, 0))) > 1 )
442 str("repeating column identifier [",
first(c_iter), "]")
449 if ( len(
first(search([
first(r_iter)], r, 0, 0))) > 1 )
450 str("repeating row identifier [",
first(r_iter), "]")
453 concat(ec1, ec2, ec3, ec4);
477 if (verbose)
log_info(
"begin table check");
482 log_warn (
"table column 0 should be 'id'");
486 if (verbose)
log_info (
"row identifier found at column zero.");
490 if (verbose)
log_info (
"checking row column counts.");
496 col_cnt == len ( r_iter ),
500 ", id=[",
first(r_iter),
"]",
501 ", has incorrect column count=[", len ( r_iter ),
"]",
502 ", expecting=[", col_cnt,
"]"
508 if (verbose)
log_info (
"checking for repeat column identifiers.");
510 if ( len(
first(search([
first(c_iter)], c, 0, 0))) > 1 )
511 log_warn ( str(
"repeating column identifier [",
first(c_iter),
"]") );
514 if (verbose)
log_info (
"checking for repeat row identifiers.");
516 if ( len(
first(search([
first(r_iter)], r, 0, 0))) > 1 )
517 log_warn ( str(
"repeating row identifier [",
first(r_iter),
"]") );
562 max ( [
for ( r_iter = r )
563 let( v =
first(r_iter) )
564 is_string(v) ? len(v) : len(
strl([v]) ) ] )
568 max ( [
for ( c_iter = c )
569 let( v =
first(c_iter) )
570 is_string(v) ? len(v) : len(
strl([v]) ) ] )
574 max ( [
for ( c_iter = c )
576 is_string(v) ? len(v) : len(
strl([v]) ) ] )
608 s = is_string(rid) ? len(rid) : len(
strl( [rid] ) )
611 chr(
consts(maxr0 - s, 32 ) )
616 s = is_string(cid) ? len(cid) : len(
strl( [cid] ) )
619 chr(
consts(maxc0 - s, 32 ) )
624 s = is_string(cdn) ? len(cdn) : len(
strl( [cdn] ) )
627 chr(
consts(maxc1 - s, 32 ) )
636 "'", rid,
"'", rid_pad,
" ",
637 cid_pad,
"'", cid,
"' (", cdn,
")", cdn_pad,
710 function qri(ri) = (ri ==
"ri") ? ri : (vri ==
true) ? ri : str(
"\"", ri,
"\"");
711 function qci(ci) = (ci ==
"ci") ? ci : (vci ==
true) ? ci : str(
"\"", ci,
"\"");
716 (ri ==
"ri")?
"":(append?str(
"_", ri):
""),
717 (ci ==
"ci")?
"":(append?str(
"_", ci):
"")
724 echo(
"Checking table...");
738 "// table value getter function",
739 (ri ==
"ri")?
"":str(
", constant row ri=", qri(ri)),
740 (ci ==
"ci")?
"":str(
", constant column ci=", qci(ci)),
743 if (comment > 0) echo (str(gct));
750 "function ", gfn(name),
752 (ri ==
"ri")?
"ri":
"",
753 (ri ==
"ri") && (ci ==
"ci")?
", ":
"",
754 (ci ==
"ci")?
"ci":
"",
755 ") = table_get_value (r=", tr,
769 if ( (ri !=
"ri") && (ci ==
"ci") )
777 gct = str(
"// get ci=", qci(i),
" (",
second(cic),
") & ri=", qri(ri),
".");
778 if (comment == 1) echo (str(gct));
784 (append?str(ri,
"_"):
""), i,
" = ",
785 gfn(name),
"(ci=", qci(i),
");",
786 (comment == 2)?str(
"\t", gct):
""
793 echo( str(
"row ri=", qri(ri),
" does not exist in table." ) );
798 else if ( (ri ==
"ri") && (ci !=
"ci") )
804 gct = str(
"// get ri=", qri(i),
" & ci=", qci(ci),
".");
805 if (comment == 1) echo (str(gct));
811 i, (append?str(
"_", ci):
""),
" = ",
812 gfn(name),
"(ri=", qri(i),
");",
813 (comment == 2)?str(
"\t", gct):
""
820 echo( str(
"column ci=", qci(ci),
" does not exist in table." ) );
825 else if ( (ri !=
"ri") && (ci !=
"ci") )
827 if ( vri || vci ||
table_exists( r=r, c=c, ri=ri, ci=ci ) )
828 { gct = str(
"// get ri=", qri(ri),
" & ci=", qci(ci),
".");
829 if (comment == 1) echo (str(gct));
836 gfn(name),
"(ri=", qri(ri),
", ci=", qci(ci),
");",
837 (comment == 2)?str(
"\t", gct):
""
847 "row ri=", qri(ri),
", column ci=", qci(ci),
848 " does not exist in table."
856 echo (
"Table has errors." );
906 heading_text =
false,
917 if ( number ==
true )
926 (heading_id && heading_text) ? str(
second(c_iter),
" (",
first(c_iter),
")")
927 : (heading_id ) ?
first(c_iter)
928 : ( heading_text) ?
second(c_iter)
932 if ( heading_id || heading_text )
951 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 count(mv, v, s=true, i)
Count all occurrences of a match value in 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.
$table_strict
<boolean> Enforce strict checking for table value references.
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, align=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.