Miscellaneous Functions

This chapter lists some useful functions from the module MAD.utility that are complementary to the standard library for manipulating files, strings, tables, and more.

Files Functions

openfile(filename_, mode_, extension_)
filexists(filename)
fileisnewer(filename1, filename2, timeattr_)
filesplitname(filename)
mockfile

Formating Functions

printf(str, ...)
fprintf(file, str, ...)
assertf(str, ...)
errorf(str, ...)

Strings Functions

strinter(str, var, policy_)
strtrim(str, ini_)
strnum(str, ini_)
strident(str, ini_)
strquote(str, ini_)
strbracket(str, ini_)
strsplit(str, seps, ini_)
strqsplit(str, seps, ini_)
strqsplitall(str, seps, ini_, r_)
is_identifier(str)

Tables Functions

kpairs(tbl, n_)
tblrep(val, n_, tbldst_)
tblicpy(tblsrc, mtflag_, tbldst_)
tblcpy(tblsrc, mtflag_, tbldst_)
tbldeepcpy(tblsrc, mtflag_, xrefs_, tbldst_)
tblcat(tblsrc1, tblsrc2, mtflag_, tbldst_)
tblorder(tbl, key, n_)

Iterable Functions

rep(x, n_)
clearidxs(a, i_, j_)
setidxs(a, k_, i_, j_)
bsearch(tbl, val, [cmp_, ] low_, high_)
lsearch(tbl, val, [cmp_, ] low_, high_)
monotonic(tbl, [strict_, ] [cmp_, ] low_, high_)

Mappable Functions

clearkeys(a, pred_)
setkeys(a, k_, i_, j_)
countkeys(a)
keyscount(a, c_)
val2keys(a)

Conversion Functions

log2num(log)
num2log(num)
num2str(num)
int2str(int)
str2str(str)
str2cmp(str)
tbl2str(tbl, sep_)
str2tbl(str, match_, ini_)
lst2tbl(lst, tbl_)
tbl2lst(tbl, lst_)

Generic Functions

same(a, ...)
copy(a, ...)
tostring(a, ...)
totable(a, ...)
toboolean(a)

Special Functions

pause(msg_, val_)
atexit(fun, uniq_)
runonce(fun, ...)
collectlocal(fun_, env_)