-
acos
aka: "arc-cosine"
function
{acos X}
Returns the arc-cosine of X, in radians.
-
add
aka: "+", "math.add"
function
{add [VAL1 [VAL2 [...]]]}
Returns the sum of all the values.
-
alert
aka: "bel", "bell", "\a"
macro
{alert}
: Alert/Bell character macro. Macro expands directly to the single-character
: String containing an alert (aka BEL) character, ASCII value 7.
-
aliases
function
{aliases EXE}
Returns a ttypes.List of the known aliases for the given executable object. This does not include the canonical
name (e.g., as returned by `exename`). This is only the built in aliases, if you've assigned the object
to another symbol, it won't show up here.
-
and
aka: "&&", "all", "exp.and"
function
{and [VAL0 [VAL1 [...]]]}
Aliases: "&&", "all"
Qualified name: "exp.and"
:If no args given, results in True. If one or more args given, results
:in True if an only if none of the arguments are equal to False.
-
append
aka: "list.append"
function
{append VAL LIST}
Qualified name: "list.append"
: Returns a new list that is the same as LIST but with VAL attached as
: a new element to the end.
: Note that the splice equivalent of append is cat, except the args
: are in a different order.
-
asin
aka: "arc-sine"
function
{asin X}
Returns the arc-sine of X, in radians.
-
at
aka: "@", "list.at"
function
{at IDX LIST}
Qualified name: list.at
Aliases: "@"
:Returns the element at index IDX in LIST. Error if IDX is out of
:bounds. negative indices are acceptable, but not END.
-
atan
aka: "arc-tangent"
function
{atan X}
Returns the arc-tangent of X, in radians.
-
atanq
aka: "atan-quad", "arc-tangent-quad"
function
{atanq Y X}
Returns the 4-quadrant arc-tangent of Y/X, in radians, taking into account the signs
of Y and X. Resulting value is between negative pi and pi.
-
block
aka: ":", "exp.block"
operator
{block [EXPR0 [EXPR1 [...]]]}
Like scope except that a new scope is NOT created.
-
bool
aka: "bool.new"
function
{bool VAL}
:If VAL is equal to "0", result value is "0", otherwise result is "1".
-
bs
aka: "\b"
macro
{backspace}
: Backspace character macro. Macro expands directly to the single-character
: String containing a backspace character, ASCII value 8.
-
bslash
aka: "\"
macro
{backslash}
: Backslash macro. Macro expands directly to the single-character
: backslash String.
-
buffer
operator
{buffer EXPR}
: Evaluates EXPR but buffers all of its output, and results in the String
: that it buffered. That means the result of EXPR is lost. You can use
: `buffer-to` if you need the result of EXPR.
-
buffer-to
operator
{buffer-to NAME EXPR}
Evaluates EXPR but buffers all of its output, and saves the string to
the symbol named NAME (using a mechanism just like `set`).
The result of this expression is the result of EXPR. If you don't need
the result of EXPR, you can use `buffer` instead.
-
caaar
aka: "first-of-first-of-first"
macro
{caaar CONS}
:Pronounces "zang"
-
caadr
aka: "first-of-first-of-rest"
macro
{caadr CONS}
:Pronounce "ka'adder"
-
caar
aka: "first-of-first"
macro
{caar CONS}
:Returns the first item of the first item of the CONS tree.
:macro expansion of {car {car CONS}}
:Pronounced with both a's distinctly: "cuh-ar", or sometimes "care".
-
cadar
aka: "first-of-rest-of-first"
macro
{cadar CONS}
:Pronounce "ka-dar"
-
caddr
aka: "first-of-rest-of-rest"
macro
{caddr CONS}
:Pronounce "ka-duh-der"
-
cadr
aka: "first-of-rest"
macro
{cadr CONS}
:Returns the first item of the rest of the CONS linked list.
:macro expansion of {car {cdr CONS}}
:Pronoucnes "ka-der"
-
call
aka: "pck.call"
function
{call EXE [ARGS]}
Qualified name: pck.call
:Resolves executable EXE then invokes it passing the List ARGS as
:arguments. Default ARGS is empty list.
-
car
aka: "first"
function
{car CONS}
:Returns the first item from the List CONS.
:An error if CONS is an empty list.
-
cat
aka: "list.cat"
function
{cat [LIST0 [LIST1 [...]]]}
Qualified name: list.cat
: REturns a new list consisting of all the given lists strung
: together. With no args, results in an empty list.
-
ccb
macro
{ccb}
"Closed Curly Brace"
Expands to String literal "}".
-
cdaar
aka: "rest-of-first-of-first"
macro
{cdaar CONS}
:Pronounce "kud-uh-ar"
-
cdadr
aka: "rest-of-first-of-rest"
macro
{cdadr CONS}
:Pronounce "kuh-dad-er"
-
cddar
aka: "rest-of-rest-of-first"
macro
{cddar CONS}
:Pronounce "kud-uh-dare"
-
cdddr
aka: "rest-of-rest-of-rest"
macro
{cdddr CONS}
:Pronounce "kuh-duh-duh-der"
-
cddr
aka: "rest-of-rest"
macro
{cddr CONS}
:Returns the rest of the rest of the CONS linked list.
:macro expansion of {cdr {cdr CONS}}.
:Pronounced like you have a stutter: "could-eder" ("ku duh der")
-
cdr
aka: "rest"
function
{cdr CONS}
:Returns the second item from the List CONS. Error if there are fewer
:than 2 elements in CONS.
:Pronounces "could-er"
-
ceil
aka: "\u2308"
function
{ceil VAL [PREC]}
Returns the ceiling of VAL, to the given PREC. PREC specifies the number of decimal digits after the decimal point to consider.
The default precision is 0, meaning he result will be an integer.
Negative values for PREC are also acceptable, in which case the specified number of digits to the left of the decimal point
are zeroed out as well. If PREC is less than 1, the result is an integer, otherwise it is a float.
-
char-at
aka: "str.at"
macro
{char-at INDEX STRING}
Qualified name: str.at
: Macro alias for {substr INDEX INDEX+1 STRING}
-
chars
aka: "str.list"
function
{chars STRING}
Qualified name: str.list
: Returns a new list whose elements are individual characters of
: STRING.
-
chr
aka: "unichr"
function
{chr VAL}
Returns a String of one character, the character has a numerical
value given by `VAL`. Note this this supports unicode characters
natively as strings are stored internally as a sequence of code points.
When it comes time to output the string, you'll need to either encode it
to bytes using the `unicode` function, or else ensure that `templ`
has been invoked with the proper output encoding.
-
close
aka: "file.close"
function
{close FD}
:Close the file. Results in ttypes.Null.
-
cons
aka: "cons.new"
function
{cons X [Y]}
Qualified name: cons.new
:Creates a new List [X, Y]. Default value for Y is an empty list
:(which typically is used to terminate linked lists and trees).
-
cons.len
function
{cons.len CONS}
:Determines the number of elements in the CONS linked list.
: Error if any of the elements in the linked list are not CONS
: cells.
-
cos
aka: "cosine"
function
{cos THETA}
Returns the cosine of angle THETA, THETA in radians.
-
cr
aka: "\r"
macro
{carriage-return}
: CR character macro. Macro expands directly to the single-character
: String containing a carriage-return character, ASCII value 13 (0x0D).
-
decode
aka: "unicode.decode"
function
{decode STRING [ENC]}
Decodes a byte string into a unicode string using the given encoding.
Internally, all strings are stored as a sequence of numerical code points
and "byte strings" and "unicode strings" are not differentiated. The
input parameter `STRING` is assumed to consist entirely of codepoints
less than 256 and further that the codepoints, treated as octets,
are valid under the specified encoding. In this case, the result of
this function is a new string whose codepoints are the decoded values.
In otherwords, this takes codepoints which have been encoded into one or
more bytes, and decodes them back into the original codepoint. Note that
this may change the length of the string.
-
deg
function
{deg RADS}
Converts RADS in radians to degrees.
-
div
aka: "math.div"
function
{div VAL1 VAL2}
Returns the quotient VAL1 / VAL2. If either VAL1 or VAL2 is floating point, does floating point division, otherwise integer
division without remainder.
-
divmod
aka: "math.divmod"
function
{divmod NUM DENOM}
Returns a List of two elements, the first is the integer quotient of NUM divided by DENOM, and the second element
is the remainder of the same.
-
doc
function
{doc EXE}
Returns documentation string for the executable object EXE.
-
dont
aka: "#", "syn", "syntax", "end-syntax", "end-syn", "rem"
operator
{dont [...]}
Aliases: "#", "syn", "syntax", "rem"
: Doesn't do anything, but must be wellformed.
: The syn and syntax aliasesare meant for use with syntax
: highlighting engines, like VIM.
-
double-quote
aka: "dq"
macro
{dquote}
: Double-quote macro. Macro expands directly to the single-character
: String containing a double-quote character.
-
eccb
macro
{eccb}
"Escaped Closing Curly Brace"
Expands to String "\}".
-
echo
aka: "exp.echo"
function
{echo [VAL0 [VAL1 [...]]]}
-
embed
function
{embed FILE}
Reads and parses FILE as a template, processing it as though its
an embedded template (except it's not terminated by >>>), and returns
the List, just like an embedded template.
This is similar to `include-as-list`, but it evaluates to-level Lists
in the template.
-
empty
aka: "mt", "is-empty", "list.empty"
function
{empty LIST}
Aliases: "mt", "is-empty", "list.empty"
:True if LIST has 0 elements in it. This is a question, not a
:constructor. You might be looking for `nil`.
-
encode
aka: "unicode.encode"
function
{encode STRING [ENC]}
Encodes the value `STRING` using the specified `ENC`, or UTF-8 if `ENC`
is not given. Strings are stored internally as a sequence of numerical
codepoints (one codepoint per character): encoding represents each
codepoint as one or more octets and results in a string where each
of the resulting octets is stored as an individual character (whose
code point is equal to the byte value).
-
eocb
macro
{eocb}
"Escaped Opening Curly Brace"
Expands to ttypes.String "\{".
-
eol
macro
{eol}
: End-of-line macro. Macro expands directly to a String object giving
: an appropriate end of line string for the current system. Usually
: "
", or just "
". This is probably only necessary when writing
: to a binary stream, otherwise just use `lnbrk` and your os will
: probably translate it.
-
eq
aka: "equal", "==="
function
{eq VAL1 VAL}
Aliases: "equal", "==="
:checks equality of two objects.
-
equiv
aka: "=="
function
{equiv VAL1 VAL2}
: Test equality of two numerical values, regardless of type. Which is
: to that for instance 2.0 == 2. But values must be numeric strings.
-
error
function
{error [VAL]}
: Raises an error with error value VAL. If nothing catches it, it
: results in an error and execution is terminated. If VAL isn't
: given, default is NULL.
-
esc-list
aka: "list.esc"
function
{esc-list LIST}
Returns a new List equivalent to the given list, but with a ' inserted as the first element.
Useful for escaping lists in macros.
-
ete
aka: "eval-this-expression"
operator
{ete ARG}
Aliases: "eval-this-expression"
See poe.
-
eval
aka: "str.eval"
function
{eval STRING}
Evaluates a string as though it's templ code. This is equivalent to writing STRING to a file
and then including that file with `include`.
-
eval-list
aka: "list.eval"
function
{eval-list LIST}
Evaluates a list as though it's a templ expression, and returns the result.
This is actually not very much like eval.
-
exec
aka: "pck.scope"
function
{exec LIST}
Qualified name: "pck.scope"
:Same as scope, but the expressesion are packed into a list, which
:means this is *not* an operator, this is a function.
-
exec-block
aka: "pck.block"
operator
{exec-block LIST}
Qualified name: "pck.block"
:Same as block, but the expressions are packed into a list.
-
exename
aka: "exe-name"
function
{exename EXE}
Returns the canonical name of the given executable object (like a function, macro, or operator).
-
exists
aka: "?"
function
{exists NAME}
Aliases: "?"
:Determines if a symbol exists with name NAME.
-
exp
aka: "math.exp", "math.e"
function
{exp [EXP]}
Return e raised to the power of EXP. Default EXP is 1.
-
false
aka: "bool.f"
macro
{false}
:Macro alias for String value "0", a Boolean false.
-
ff
aka: "\f"
macro
{formfeed}
: Formfeed character macro. Macro expands directly to the single-character
: String containing a formfeed character, ASCII value 12 (0x0C).
-
fields
aka: "plist.fields"
function
{fields PLIST}
Returns a list of all the field names in the given PLIST.
-
file-get-contents
function
{file-get-contents FILENAME [MODE]}
Reads the contents of specified file at the specified path in the filsystem,
and results in the contents as a string. This is a convenience function to avoid
creating a file descriptor for the file. If MODE is not specified, it is opened for
reading in text mode.
-
file-put-contents
function
{file-put-contents FILENAME [MODE] CONTENTS}
Writes the specified String CONTENTS to the indicated file on the filesystem.
FILENAME should be a file system path, not a file descriptor. This is a convenience
function for not having to create a file descriptor for the file.
Reuslt is Null
If MODE is not specified, it is opened for writing in text mode.
-
filepos
aka: "str.filepos"
function
{filepos VAL}
-
filepos-plist
aka: "plist.filepos"
function
{filepos-plist VAL}
-
filepos-tuple
aka: "list.filepos"
function
{filepos-tuple VAL}
-
find
aka: "list.find"
function
{find NEEDLE [START] [END] HAYSTACK}
Qualified name: list.find
: Finds the index into HAYSTACK of the first occurence of something
: equal to the value NEEDLE, which can be any type. START and END are
: as with strpos. Returns ttypes.Null if not found.
-
flatten
aka: "list.flatten"
function
{flatten LIST}
Qualified name: list.flatten
Returns flattened version of the list: when a nested list is found,
it is flattened and the flattened version is expanded to take it's
place.
-
floor
aka: "\u230A"
function
{floor VAL [PREC]}
Returns the floor of VAL, to the given PREC. PREC specifies the number of decimal digits after the decimal point to consider.
The default precision is 0, meaning he result will be an integer.
Negative values for PREC are also acceptable, in which case the specified number of digits to the left of the decimal point
are zeroed out as well. If PREC is less than 1, the result is an integer, otherwise it is a float.
-
for
aka: "for.loop"
operator
{for NAME INTHIS [WHILE] DO}
: Loops over the values in list `INTHIS`. Before iterating, a new
: scope is pushed to the stack. For each iteration, the symbol
: named by `NAME` is assigned the next value from `INTHIS`, and
: then the expression `IF` is evaluated: if the result is the
: String "0", then this iteration is skipped, but the loop is
: *not* aborted. Otherwise, this iteration is performed by
: evaluating the expression `DO`.
:
: The resulting value is the result of the last evaluation of
: `DO`. If any evaluations of `DO` is a Return value, the loop is
: aborted (no further iterations are performed) and the Return
: value is stripped to give the result.
-
gen
aka: "for.gen"
operator
{gen NAME INTHIS [WHILE] DO}
: Runs like a `for` loop but a list is built from the results of
: each evaluation of `DO`. It's a list comprehension.
-
gen-loop
aka: "loop.gen"
operator
{gen-loop [[INIT] [TEST] [POST]] DO}
Aliases: "loop.gen"
:Like `gen`, but uses the LOOP loop setup instead of FOR loop.
-
gen-while
aka: "while.gen"
operator
{gen-while TEST DO}
:Like `gen`, but uses the WHILE loop setup instead of FOR loop.
-
get
macro
{get NAME}
:Macro alias for {getset NAME}, returns the value of symbol NAME.
-
getf
aka: "plist.get"
function
{getf LABEL LIST}
Qualified name: plist.get
:Returns the element in LIST immediately following the element which
:is equal to LABEL. Error if no LABEL is not found in LIST, or if
:there is no element following it.
-
getset
aka: "$"
function
{getset NAME [VALUE]}
Aliases: "$"
:If two arguments are given, sets the value of the lowest occurence of
:NAME in the stack to VALUE, and results in VALUE. If the value
:doesn't exist, it's created in the current (lowest) scope.
:
:If one argument is given, just looks up NAME in the stack and returns
:the value. Error if no such symbol exists.
-
glue
aka: "str.cat", "><"
macro
{glue [VAL0 [VAL1 [...]]])
Possible Alias: "><"
Qualified name: str.cat
: macro alias for {join "" ... }
-
gmtime
aka: "utctime", "time.utctime"
function
{gmtime [STAMP]}
Returns a List representing the data/time components of the specified time, or the current time
if STAMP is not given. STAMP, if given, should be like the output of `stamp`.
Returned value represents greenwhich mean time. Use `time` (aka `localtime`) for local time.
The returned list has 9 elements: year, month, day (of the month), hour, min, sec, weekday,
year day, is-DST. This matches the standard C struct tm, or the python time.struct_time object.
Note that the different between GMT (aka UT1) and UTC is irrelevant as 1 second resolution: they
are not allowed to differ by more than 0.9 seconds, so they are the same at this level.
-
gt
aka: ">"
function
-
gte
aka: ">="
function
-
hasf
aka: "plist.has"
function
{hasf LABEL LIST}
Qualified name: plist.has
:Determines if LABEL exists in the given LIST and is NOT the last
:element of the list. I.e., whether or not LABEL will work in a call
:to getf.
-
idxf
aka: "plist.idx"
function
{idxf LABEL PLIST}
Qualified name: plist.idx
: Returns the numerical index into the given plist of the field with
: the given label. This is the index of the *value*, not the label.
: The label is always at the previous index.
:
: If not found, returns None.
-
if
operator
{if IF0 THEN0 [IF1 THEN1 [IF 2 THEN2 [...]]] [ELSE] }
: Operator for conditional execution. Evalutes each of the IF
: expressions one at a time. The first that evaluates to anything
: other than "0" has it's corresponding (subsequent) THEN
: expression evaluated, and the result of that eval is the result
: of the `if` expression. If all of the IFs evaluate to "0", then
: the ELSE is evaluated and the result is the result of this.
:
: If nothing is evaluated, result is ttypes.Null.
-
implode
aka: "imp", "pck.join"
function
{implode [GLUE] LIST}
-
in
aka: "list.in"
macro
{in NEEDLE [START] [END] HAYSTACK}
Qualified name: list.in
: Macro alias for {not {is-null {find NEEDLE START END HAYSTACK}}}.
-
in-str
aka: "str.in"
macro
{in-str NEEDLE [START] [END] HAYSTACK}
Qualified name: str.in
:Macro alias for {not {is-null {strpos NEEDLE START END HAYSTACK}}}.
-
include
function
{include FILE}
-
include-as-list
function
{include-as-list FILE}
Parses the contents of the specified FILE as a templ template, returns a List
describing the contents of template. Similar to `embed`, but this doesn't eval
anything in the include file.
-
insert
aka: "list.insert"
function
{insert VAL [IDX] LIST}
Qualified name: "list.insert"
:returns a new list which is the same as LIST except that it has a new
:value VAL inserted so that it is at index IDX. The value that used to
:be at index IDX, and all values are higher indicies, are moved up by
:one index. If IDX isn't given, default is 0 (front of the list).
:
:Special value END is allowed for IDX, then it works like append.
-
invoke
aka: "exp.call"
function
{invoke EXE [ARG0 [ARG1 [...]]]}
Qualified name: exp.call
:Same as call, but arguments are unpacked.
-
is-exe
aka: "exe.is"
function
{is-exe X}
Returns "1" is X is an Executable, "0" otherwise.
-
is-false
aka: "not"
function
{is-false VAL}
Aliases: "not"
:If VAL is equal to "0", result value is "1", otherwise result is "0".
-
is-func
aka: "func.is"
function
{is-func X}
Returns "1" is X is a Function Executable, "0" otherwise.
-
is-list
aka: "list.is"
function
{is-list X}
Returns "1" is X is a List, "0" otherwise.
-
is-macro
aka: "macro.is"
function
{is-macro X}
Returns "1" is X is a Macro Executable, "0" otherwise.
-
is-null
aka: "null.is"
function
{is-null X}
Qualified name: null.is
Returns "1" is X is ttypes.Null, "0" otherwise.
-
is-oper
aka: "oper.is"
function
{is-oper X}
Returns "1" is X is an Operator Executable, "0" otherwise.
-
is-str
aka: "str.is"
function
{is-str X}
Returns "1" is X is a String, "0" otherwise.
-
is-true
function
{is-true VAL}
:If VAL is equal to "1", result value is "1", otherwise result is "0".
-
join
aka: "exp.join", ">*<"
function
{join GLUE [VAL0 [VAL1 [...]]])
Possible Alias: ">*<"
Aliases: "exp.join" as in "expanded" because the args are not packed into a list.
: Like implode, but the values are unpacked instead of in a list.
-
lambda
operator
{lambda [[DOC] ARGNAMES] EXPR}
-
len
aka: "list.len"
function
{len LIST}
Qualified name: "list.len"
:Returns the number of elements in List LIST.
-
let
aka: "exp.let"
function
{let [NAME0 [NAME1 [...]]]}
Qualified name: exp.let
:Adds new symbols to the lowest scope in the stack.
Returns null.
-
list
aka: "'", "list.new"
function
{list [VAL1 [VAL2 [...]]] }
Returns a List of the given elements.
-
lnbrk
aka: "\n"
macro
{lnbrk}
Aliases: "\n"
: Line-break macro. Macro expands directly to the single-character
: String with ASCII value 0x0A (decimal 10). This is the traditional
: "linebreak" character, often escaped in other programming languages
: as "
". Note that templ has no escapes in strings or string
: literals.
-
localtime
aka: "time", "time.time"
function
{localtime [STAMP]}
Returns a List representing the date/time components of the specified time, or the current time
if STAMP is not given. STAMP, if given, should be like the output of `stamp`.
Returned value represents local time. Use `gmtime` for UTC time.
The returned list has 9 elements: year, month, day (of the month), hour, min, sec, weekday,
year day, is-DST. This matches the standard C struct tm, or the python time.struct_time object.
-
log
aka: "ln"
function
{log VAL [BASE]}
Returns the logarithm of VAL in base BASE. If BASE is not given, it's a natural log (BASE is 'e').
-
loop
aka: "loop.loop"
operator
:{loop [INIT] [TEST] [POST] DO}
:{loop [INIT] TEST [POST] DO}
:{loop [INIT] TEST POST DO}
:
:Works like a C-style for loop: it pushes a new scope to the stack, then evaluates INIT.
:Then it begins to loop: at the start of the loop, it evaluates TEST: if that evaluates to "0",
:it's done, otherwise it evaluates DO, then evaluates POST, then does the next iteration of the
:loop, starting with evaluation of TEST again.
:
:With three argument, INIT is not used. With two arguments, neither INIT nor POST are used.
:With only one argument, only DO is used, so it just keeps going until DO evaluates to a RETURN.
:
:The resulting value is the result of the last evaluation of
:`DO`. If any evaluations of `DO` is a Return value, the loop is
:aborted (no further iterations are performed) and the Return
:value is stripped to give the result.
-
lt
aka: "<"
function
-
lte
aka: "<="
function
-
macro
operator
{macro [[DOC] ARGNAMES] EXPR}
-
macro-subst
aka: "macro.subst"
operator
{macro-subst MACRO [ARG0 [ARG1 [...]]]}
Executes the given MACRO with the given args, but does not evaluate the resuting
subst as would usually happen when a macro is executed, just returns the subst
directly.
-
mod
aka: "div.mode"
function
{mod VAL MOD}
Returns VAL reduced modulo MOD. To get both the quotient and the remainder, use `divmod`.
-
mult
aka: "*", "math.mult"
function
{mult [VAL1 [VAL2 [...]]]}
Returns the product of all the values.
-
neg
aka: "math.neg"
macro
{neg VAL}
Returns the negative of VAL, expands to {sub VAL}
-
neq
aka: "not-equal", "!=="
function
{neq VAL1 VAL}
Aliases: "not-equal", "!=="
:checks equality of two objects.
-
nequiv
aka: "!="
function
-
nil
aka: "list.nil"
macro
{nil}
Qualified name: "list.nil"
:Creates a new empty array. This is a macro expansion of {' }.
-
ocb
macro
{ocb}
"Opening Curly Brace"
Expands to String literal "{".
-
open
aka: "file.open"
function
{open NAME MODE}
:Results in a string giving the file descriptor (FD) of an opened
file.
-
or
aka: "||", "any", "exp.or"
function
Aliases: "||", "any"
Qualified name: "exp.or"
:If no args given, results in False. If one or more args given,
:results in True if any of the arguments are not equal to True.
-
ord
function
{ord CHAR}
: Returns a ttypes.String representing the integer value of the single
: character CHAR. CHAR must be a String, and must have exactly one
: character, otherwise you get an exception. You can use `ord1`
: instead.
-
ord-1
function
{ord-1 CHAR}
Same as ord, but doesn't care if CHAR has more than one character
or not, it just gives the ORD of the first character.
-
pck.let
function
{pck.let LIST}
:For each element in LIST, a new symbol with that name is created in
:the lowest scope on the stack.
:Elements of LIST must all be Strings.
-
pi
aka: "\u03C0"
macro
{pi}
Macro expands to the value of pi.
-
pipe
function
{pipe COMMAND [[EC-NAME] STDIN]}
Uses the system's command processor to execute the given COMMAND String, like `system`, but
the given String STDIN is piped into the process, and instead of piping the output to this processes
output stream, it buffers it into a string and returns it as the resulting value. If EC-NAME is given,
the commands error-code is stored at the symbol (as with `getset`).
-
pipe-both
function
{pipe-both COMMAND [[EC-NAME] STDIN]}
Like `pipe`, but returns a two-tuple List: (out, err), where out is what was written to the
process's STDOUT, and err is what was written to it's STDERR.
-
plist.find
function
{plist.find VALUE PLIST}
: Finds the index into PLIST of the first occurence of something
: equal to VALUE , which can be any type. Note this is only checking
: values, not fields (i.e., only the even indices), and returns the
: index of that value. The label for the field is always at the
: previous index.
-
plist.in
macro
Qualified name: plist.in
: Macro alias for {not {is-null {plist.find VALUE PLIST}}}.
-
plist.len
function
x {plist.len PLIST}
:Returns the number of *fields* in the given PLIST. A field is a pair
:of subsequent elements in a List: LABEL VALUE. So a List with 4
:elements has 2 fields as a plist. Note that a final odd-indexed
:element is not considered part of a plist, so is not included in the
:length.
-
poe
operator
{poe ARG}
Aliases: NO ALIASES: We have to look for the specific value "poe". This
is basically syntax, not a normal executable.
More powerful than vota, this actually searches recursively through
ARG and when it finds a list that starts with ete, it evaluates it in place.
On the other hand, when it finds a nested "poe", it doesn't evaluate it or
recurse into it.
-
pow
aka: "**", "math.pow"
function
{pow BASE EXP}
Returns the value of BASE raised to power EXP.
-
q-mark
aka: "\?"
macro
{question}
: Question macro. Macro expands directly to the single-character
: question-mark String.
-
quote
aka: "''"
macro
{quote STR}
Puts double-quotes around the given string, expands as a macro to {wrap "\"" STR}.
This does NOT escape quote characters that may already be inside STR.
-
rad
function
{rad DEG}
Converts DEG in degrees to radian.
-
rand
aka: "randint", "random.int"
function
{rand [MAX]}
Returns a pseudo-random integer in the closed range [0, MAX]. If MAX is not given,
2^32 is used.
All of these random functions use an unspecified RNG which is up to the implementation.
That is also why there is no seed function because a seed function implies that if
you start with the same seed, you'll always get the same values, which isn't necessarily
true if the implementation uses a HW RNG, or if you move to a different implementation.
-
rand-float
aka: "random.float"
function
{rand-float}
Returns a pseudo-random floating-point value in the semi-open range [0.0, 1.0).
See `rand` for details.
-
range
function
{range [START] STOP [STEP]}
:Produces a ttypes.List consisting of numeric values starting with START, incrementing by STEP,
:and ending before getting to STOP. Default START is 0, default STEP is 1. If any values
:are floats, the resulting elements are floats.
:One argument works as {range 0 STOP 1}.
:Two arguments works as {range START STOP 1}.
-
read
aka: "file.read"
function
{read FD [COUNT]}
Reads data from the file designate by FD, up to the specified COUNT number of characters.
If COUNT is not given, reads until the EOF. Results in a String of the read data.
-
redirect
operator
{redirect FD EXPR}
: First evaluates FD, then evaluates EXPR but redirecting all of the
: expressions output to the specified FD file. Result is the result of
: EXPR.
-
return
function
{return [VAL]}
Returns a new Return object, wrapping VAL if given.
-
reverse
aka: "list.reverse"
function
{reverse LIST}
Qualified name: list.reverse
: Returns a copy of LIST in the opposite order.
-
round
function
{round VAL [PREC]}
Returns the VAL, rounded to the given PREC. PREC specifies the number of decimal digits after the decimal point to consider.
The default precision is 0, meaning he result will be an integer.
Negative values for PREC are also acceptable, in which case the specified number of digits to the left of the decimal point
are zeroed out as well. If PREC is less than 1, the result is an integer, otherwise it is a float.
-
scope
aka: "::", "exp.scope"
operator
{scope [EXPR0 [EXPR1 [...]]]}
Aliases: "::"
Qualified name: "exp.scope"
: Executes each EXPRn one at a time, resulting value is the resulting
: value of the last expression executed. If any value results in a
: Retrun object, no further statements are executed. The return object
: itself is still the resulting value, it is not unwrapped.
:
: Execution occurs in a new scope which is popped before the
: expressino concludes.
-
set
aka: "$="
macro
{set NAME VALUE}
Aliases: "$="
:Macro alias for {getset NAME VALUE}.
-
sin
aka: "sine"
function
{sin THETA}
Returns the sine of angle THETA, THETA in radians.
-
single-quote
aka: "sq", "\'"
macro
{squote}
: Single-quote macro. Macro expands directly to the single-character
: String containing a single-quote character.
-
slice
aka: "list.slice"
function
{slice FIRST [END] LIST}
Qualified name: list.slice
:Returns a new List with the specified elements of List. Starts at
:FIRST, ends right before END. If END isn't given, it's the length of
:the list. Not an error for END to go past the end of the list, it
:just truncates.
-
sort
aka: "list.sort"
function
{sort LIST}
Returns a new list containing all of the elements in LIST, but sorted in lexicographical order. Sorting
only works for lists that contain only string, otherwise it is an error.
-
spit
aka: "pck.echo"
macro
{spit LIST}
-
splice
aka: "list.splice"
function
{splice THIS [IDX] INTO}
Qualified name: "list.splice"
:Like insert, except in this case THIS is a ttypes.List of items which are
:all inserted into the target list `INTO`.
:
:Special value END is allowed for IDX, then it works like cat but with
:arguments in reverse order.
-
sqrt
function
{sqrt VAL}
Returns the square root of VAL.
-
stamp
aka: "time.stamp"
function
{stamp [LIST]}
Returns the current UNIX timestamp, the number of seconds elapsed since Midnight on Jan 1 1970 UTC.
Or, if LIST is given, it should be as the output of `localtime` or `gmtime`, and the corresponding
timestamp for the time it represents is returned.
-
stderr
function
{stdout}
:Results in the STDERR FD.
-
stdin
function
{stdin}
:Results in the STDin FD.
-
stdout
function
{stdout}
:Results in the STDOUT FD.
-
str
aka: "str.new"
function
{str VAL}
Qualified name: str.new
: Converts VAL to a String form, regardless of it's Type.
-
str.reverse
function
{str.reverse STRING}
Returns a new String with is the reverse of the given `STRING`.
-
strlen
aka: "str.len"
function
{strlen STRING}
Qualified name: str.len
:Returns the number of characters in STRING.
-
strpos
aka: "str.find"
function
{strpos NEEDLE [START [END]] HAYSTACK}
Searches for the index of the first occurrence of NEEDLE in
HAYSTACK, starting no SOONER than START and ending *before* END. If
three args given, END is defualt. Default START is 0, Default END is
to search the length of the string (search all the way to the end).
Returns ttypes.Null if not found, otherwise a *positive* index into
HAYSTACK.
The special value "END" (case sensitive) is acceptable for the `END` argument.
See `substr` for details.
-
strrep
function
{strrep THIS WITHTHIS INHERE [COUNT]}
Replaces occurences of String THIS in String INHERE with the String WITHTHIS. If COUNT is given, it performs at most
that many replacements, leaving the rest. If not given, perform all replacements in the string.
-
sub
aka: "-", "math.sub"
function
{sub [VAL1] VAL2}
With two arguments, returns VAL1 - VAL2. With one argument, returns
-(VAL2).
-
substr
aka: "str.slice"
function
{substr FIRST [END] STRING}
Qualified name: str.slice
Returns a substring of `STRING` starting with index `FIRST` and
ending immediately before index `END`, or the end of the string
whichever comes first. Not an error if `END` runs past the end of the
string. If it does not run past, then the length of the string is
END - FIRST. If FIRST is not less than END, then it is an empty string.
Negative indices are valid, they specify distances from the end of the
string, so -1 is the last character. I.e., if FIRST is -1 and END is
unspecified, it will return the last character of the string.
END can also be the special string "END" (case sensitive), as an
alternative to not specifying it. In otherwords, that means it will
go all the way to the end.
-
system
function
{system COMMAND}
Invoke the system's command processor to execute the given COMMAND String, piping STDOUT from the
command to the output stream, and returning the exit code. STDERR from the stream is written to
STDERR of this process.
-
tab
aka: "\t"
macro
{tab}
Aliases: "\t"
: Tab macro. Macro expands directly to the single-character
: String with ASCII value 9. This is the traditional
: "horizontal tab" character, often escaped in other programming languages
: as " ". Note that templ has no escapes in strings or string
: literals.
-
tan
aka: "tangent"
function
{tan THETA}
Returns the tangent of angle THETA, THETA in radians.
-
tau
aka: "\u03C4"
macro
{tau}
Returns twice the transcendtal number pi.
-
time-plist
aka: "time.toPlist"
function
{time-plist TM-LIST}
Given a TM struct as a list, like returned by `localtime` or `gmtime`, converts it to a plist
with field names corresponding to the C standard fields of the tm struct, but without the leading
"tm_". So we have ":year", ":mon", ":mday", ":hour", ":min", ":sec", ":wday", ":yday", and ":isdst".
-
to-lower
aka: "str.lower"
function
{to-lower STRING}
: Returns a copy of STRING with all character replaced by lower-case
: versions.
-
to-upper
aka: "str.upper"
function
{to-upper STRING}
: Returns a copy of STRING with all character replaced by upper-case
: versions.
-
true
aka: "bool.t"
macro
{true}
:Macro alias for String value "1", a Boolean true.
-
try
operator
{try EXPR [[NAME] CATCH]}
: Evaluates EXPR, but if any errors occur, they are trapped. If
: CATCH is given, it is evaluated as an EXPR if and only if an
: error occurs. A new scope is pushed before execution and popped
: afterwards. If NAME is given, the error value is assigned to
: a symbol name NAME in this new scope, before evaluating CATCH.
:
: If an error occurred, the result is the result of CATCH, otherwise
: it's just the result of EXPR.
-
type
function
{type VALUE}
Returns a string describing the type of VALUE.
-
unpack
aka: ",="
function
{unpack NAMES [REST] VALUES}
For lists NAMES and VALUES, assigns values from VALUES into variables named by the corresponding element of NAMES.
Acceptable for VALUES to have more elements than NAMES. In this case, if REST is given, then it is the name of a
variable which will be assigned the remaining elements of VALUES (as a list). If REST isn't given, unassigned
values from VALUES are just not assigned.
If there are more NAMES than VALUES, it's an error. If REST is given and there are no values from VALUES that
are left unassigned, then REST will be assigned an empty list.
Resulting value is NULL.
-
unret
function
{unret RET}
: Unwraps a Return value, resulting in the value that the Return
: value wraps.
-
vars
function
{vars}
Returns a ttypes.List of all the variable (names) in the stack.
-
ver-date
aka: "str.ver-date"
function
{ver-date}
Returns the version-date-string of templ.
-
version
aka: "str.version"
function
{version}
Returns the version string of templ.
-
version-plist
aka: "plist.version"
function
{version-plist}
Returns the version of templ as a Plist with fields ":major", ":minor", ":patch", ":semantic",
":tag", ":year", ":month", ":day"
-
version-tuple
aka: "list.version"
function
{version-tuple}
Returns the version of templ as a tuple: (MAJOR, MINOR, PATCH, SEMANTIC, TAG, YEAR, MONTH, DAY)
-
void
aka: "v"
operator
{void [EXPR]}
Aliases: "v"
:Evaluates EXPR unconditionally but results in a ttypes.Null value
:regardless.
-
vota
aka: "value-of-the-argument", "$$"
operator
{vota ARG}
Aliases: "value-of-the-argument", "$$"
Very useful operator for defining macros: simply returns the parsed by
Unprocessed value of the first (and only) arguments.
-
vt
aka: "\v"
macro
{vertical-tab}
: Vertical tab character macro. Macro expands directly to the single-character
: String containing a vertical-tab character, ASCII value 11 (0x0B).
-
while
aka: "while.loop"
operator
{while TEST DO}
: A simple loop. For each iteration, evaluates the expression
: `TEST`: if it's equal to "1" then we perform the iteration by
: evaluating `DO`, otherwise we abort the loop.
:
: A new scope is pushed before any iterations, and opped before
: returning.
:
: The resulting value is the result of the last evaluation of
: `DO`. If any evaluations of `DO` is a Return value, the loop is
: aborted (no further iterations are performed) and the Return
: value is stripped to give the result.
-
wrap
macro
{wrap WITH [ANDTHIS] STRING}
Expands to {join "" WITH STRING ANDTHIS}. If ANDTHIS is not given, it's WITH.
-
write
aka: "file.write"
function
{write FD STR}
Writes the String STR to an open file identified by FD.
Results in the number of bytes written.
-
xor
function