dt

duct tape for your unix pipes


dt 1.2.0 standard library

%( <a> <b> -- <c> ) Modulo two numeric values. In standard notation: a % b = c
*( <a> <b> -- <c> ) Multiply two numeric values.
+( <a> <b> -- <c> ) Add two numeric values.
-( <a> <b> -- <c> ) Subtract two numeric values. In standard notation: a - b = c
...( <original> -- ? ) Unpack a quote.
.s( -- ) Print the state of the process: all available values.
/( <a> <b> -- <c> ) Divide two numeric values. In standard notation: a / b = c
:( ... [<name>] -- ) Bind variables to a quote of names.
abs( <a> -- <b> ) Determine the absolute value of a number.
alias( <prevname> <newname> -- ) Alias a new command from another, copying the description of the previous command.
and( <a> <b> -- <bool> ) Determine if two values are both truthy.
any?( <original> <condition> -- <bool> ) Determine whether any value in a quote passes a condition. Stops at the first truthy result.
anything?( -- <bool> ) True if any value is present.
appendf( <contents> <filename> -- ) Write a string to a file. If a file previously existed, the new content will be appended.
args( -- [<arg>] ) Produce the arguments provided to the process when it was launched.
assert-true( <cond> <message> -- ) Naive assertion that requires a condition to be truthy. If falsy, it will print a message to standard error and fail with an exit code of 1.
cd( <dirname> -- ) Change the process's working directory.
chars( <string> -- [<substring>] ) Splits a string into individual characters, where a character is a single byte. (Not friendly to UTF-8 runes.)
concat( [<a>] [<b>] -- [<c>] ) Concatenate two quotes. Values are coerced into quotes. (For String concatenation, see join.)
contains?( <haystack> <needle> -- <bool> ) With Strings, determine if a string contains a substring. With quotes, determine if a quote contains a value.
cwd( -- <dirname> ) Produce the current working directory.
def( <action> <name> -- ) Define a command.
def!( <action> <name> -- ) Defines a new command. If nested, any commands or variables defined will be available in the calling scope.
def-usage( <name> <description> -- ) Define the usage notes of a given command.
def?( <name> -- <bool> ) Determine whether a command is defined.
define( <action> <description> <name> -- ) Define a command with a description.
defs( -- [<name>] ) Produce a quote of all defined commands.
deq( [<a>] -- <b> [<c>] ) Dequeue the first value from a quote.
divisor?( <a> <b> -- <bool> ) Determine if a number a is evenly divisible by number b.
do( <action> -- ? ) Execute an action.
do!( <action> -- ? ) Execute an action. If nested, any commands or variables defined will be available in the calling scope.
do!?( <action> <condition> -- ? ) Conditionally execute an action. If nested, any commands or variables defined will be available in the calling scope.
do?( <action> <condition> -- ? ) Conditionally execute an action.
doin( <context> <action> -- ) Execute an action in a context.
downcase( <string> -- <lower> ) Convert a string to its lowercase form.
drop( <a> -- ) Drop the most recent value.
dup( <a> -- <a> <a> ) Duplicate the most recent value.
each( [<a>] <action> -- ) Perform a given action with each value in a quote.
ends-with?( <string> <suffix> -- <bool> ) Determine if a string ends with a suffix.
enl( -- ) Print a newline to standard error.
enq( <a> [<b>] -- [<c>] ) Enqueue a value into a quote as its new first value.
ep( <a> -- ) Print the most recent value to standard error.
epl( <a> -- ) Print the most recent value and a newline to standard error.
epls( [<a>] -- ) Print the values of the most recent quote, each followed by a newline, to standard error.
eprint( <a> -- ) Print the most recent value to standard error.
eprintln( <a> -- ) Print the most recent value and a newline to standard error.
eprintlns( [<a>] -- ) Print the values of the most recent quote, each followed by a newline, to standard error.
eq?( <a> <b> -- <bool> ) Determine if two values are equal. Works for most types with coercion.
evaleval
even?( <a> -- <bool> ) Determine if a number is even.
exec( <process> -- ) Execute a child process (from a String). When successful, returns stdout as a string. When unsuccessful, prints the child's stderr to stderr, and returns boolean false.
exit( <exitcode> -- ) Exit with the specified exit code.
filter( <original> <condition> -- <preserved> ) Require some condition of all values in a quote. Truthy results are preserved, and falsy results are not.
first( [<a>] -- <b> ) The first element of a quote.
green( -- ) Print a control character for green and bold (for the colorblind) to standard output and standard error.
gt?( <a> <b> -- <bool> ) Determine if a value is greater than another. In standard notation: a > b
gte?( <a> <b> -- <bool> ) Determine if a value is greater-than/equal-to another. In standard notation: a ≧ b
help( -- ) Print commands and their usage
inspire( -- <wisdom> ) Get inspiration.
interactive?( -- <bool> ) Determine if the input mode is interactive (a TTY) or not.
join( [<substring>] <delim> -- <string> ) Join strings with a delimiter.
last( [<a>] -- <b> ) The last element of a quote.
len( <a> -- <length> ) The length of a string or quote. (Always 1 for single values.)
lines( <string> -- [<substring>] ) Splits a string on newlines.
loop( <action> -- ? ) Execute an action forever until it fails.
ls( -- [<filename>] ) Produce a quote of files and directories in the process's working directory.
lt?( <a> <b> -- <bool> ) Determine if a value is less than another. In standard notation: a < b
lte?( <a> <b> -- <bool> ) Determine if a value is less-than/equal-to another. In standard notation: a ≦ b
map( <original> <action> -- <transformed> ) Apply an action to all values in a quote.
nand( <a> <b> -- <bool> ) Determine if two values are not both truthy.
neq?( <a> <b> -- <bool> ) Determine if two values are unequal.
nl( -- ) Print a newline to standard output.
nor( <a> <b> -- <bool> ) Determine if neither of two values are truthy.
norm( -- ) Print a control character to reset any styling to standard output and standard error.
not( <a> -- <bool> ) Determine the inverse truthiness of a value.
odd?( <a> -- <bool> ) Determine if a number is odd.
or( <a> <b> -- <bool> ) Determine if either of two values are truthy.
p( <a> -- ) Print the most recent value to standard output.
parse-csv( <string> -- [[<cells>]] ) Naive conversion of a raw string in comma-separated value (CSV) format to a quote of lines of cells
pl( <a> -- ) Print the most recent value and a newline to standard output.
pls( [<a>] -- ) Print the values of the most recent quote, each followed by a newline, to standard output.
pop( [<a>] -- [<b>] <c> ) Pop the last value from a quote.
print( <a> -- ) Print the most recent value to standard output.
println( <a> -- ) Print the most recent value and a newline to standard output.
printlns( [<a>] -- ) Print the values of the most recent quote, each followed by a newline, to standard output.
procname( -- <name> ) Produce the name of the current process. This can be used, for example, to get the name of a shebang script.
push( [<a>] <b> -- [<c>] ) Push a value into a quote as its new last value.
pwd( -- ) Print the current working directory to standard output.
quit( -- ) Quit. Prints a warning if there are any values left on stack.
quote( <a> -- [<a>] ) Quote a value.
quote-all( ? -- [<?>] ) Quote all current context.
rand( -- <a> ) Produces a random integer.
read-line( -- <line> ) Read a string from standard input until newline.
read-lines( -- [<line>] ) Read strings, separated by newlines, from standard input until EOF. (For example: until ctrl+d in a Unix-like system, or until a pipe is closed.)
readf( <filename> -- <contents> ) Read a file's contents as a string.
readln( -- <line> ) Read a string from standard input until newline.
readlns( -- [<line>] ) Read strings, separated by newlines, from standard input until EOF. (For example: until ctrl+d in a Unix-like system, or until a pipe is closed.)
red( -- ) Print a control character for red to standard output and standard error.
replrepl
rev( <original> -- <reversed> ) Reverse a quote or string. Other types are unmodified.
rl( -- <line> ) Read a string from standard input until newline.
rls( -- [<line>] ) Read strings, separated by newlines, from standard input until EOF. (For example: until ctrl+d in a Unix-like system, or until a pipe is closed.)
rot( <a> <b> <c> -- <c> <a> <b> ) Rotate the three most recent values.
shebang-argsshebang-args
sort( [<a>] -- [<b>] ) Sort a list of values. When values are of different type, they are sorted in the following order: bool, int, float, string, command, deferred command, quote.
split( <string> <delim> -- [<substring>] ) Split a string on all occurrences of a delimiter.
starts-with?( <string> <prefix> -- <bool> ) Determine if a string starts with a prefix.
status( -- ) Print the state of the process: all available values.
swap( <a> <b> -- <b> <a> ) Swap the two most recent values.
times( <action> <n> -- ? ) Perform a given action n times.
to-bool( <a> -- <bool> ) Coerce a value to a boolean.
to-cmd( <a> -- <cmd> ) Coerce a value to a command.
to-def( <a> -- <def> ) Coerce a value to a deferred command. (Read as "definition" or "deferred".)
to-float( <a> -- <float> ) Coerce a value to a floating-point number.
to-int( <a> -- <int> ) Coerce a value to an integer.
to-quote( <a> -- [<a>] ) Coerce value to a quote. To quote a quote, use quote.
to-string( <a> -- <string> ) Coerce a value to a string.
undef?( <name> -- <bool> ) Determine whether a command is undefined.
unlines( [<substring>] -- <string> ) Joins strings with newlines.
unquote( <original> -- ? ) Unpack a quote.
unwords( [<substring>] -- <string> ) Joins strings with spaces.
upcase( <string> -- <upper> ) Convert a string to its uppercase form.
usage( <name> -- <description> ) Print the usage notes of a given command.
version( -- <version> ) Produce the version of dt in use.
while( <action> <cond> -- ? ) Perform an action while the condition is truthy.
words( <string> -- [<substring>] ) Splits a string on spaces.
writef( <contents> <filename> -- ) Write a string as a file. If a file previously existed, it will be overwritten.