-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstdlib.html
149 lines (149 loc) · 15.4 KB
/
stdlib.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!doctype html>
<html>
<head>
<title>dt: standard library</title>
<link rel='stylesheet' href='//cdn.jsdelivr.net/npm/hack-font@3/build/web/hack.css'>
<link rel='stylesheet' href='style.css'>
</head>
<body>
<div id='wide-strip'>
<header><center><a href='/'>
<h1 id='logo'>dt</h1>
<h2><pre>duct tape for your unix pipes</pre></h2>
</a></center></header>
<main>
<hr>
<center><h2>dt 1.3.0 standard library</h2></center>
<table id='stdlib'>
<tr><td class='green'>%</td><td>( x y -- z ) Modulo two numeric values. In standard notation: a % b = c</td></tr>
<tr><td class='green'>*</td><td>( x y -- z ) Multiply two numeric values.</td></tr>
<tr><td class='green'>+</td><td>( x y -- z ) Add two numeric values.</td></tr>
<tr><td class='green'>-</td><td>( x y -- z ) Subtract two numeric values. In standard notation: a - b = c</td></tr>
<tr><td class='green'>...</td><td>( [...] -- ... ) Unpack a quote.</td></tr>
<tr><td class='green'>.s</td><td>( -- ) Print the state of the process: all available values.</td></tr>
<tr><td class='green'>/</td><td>( x y -- z ) Divide two numeric values. In standard notation: a / b = c</td></tr>
<tr><td class='green'>:</td><td>( ... [name] -- ) Bind variables to a quote of names.</td></tr>
<tr><td class='green'>abs</td><td>( x -- y ) Determine the absolute value of a number.</td></tr>
<tr><td class='green'>alias</td><td>( prev new -- ) Alias a new command from another, copying the description of the previous command.</td></tr>
<tr><td class='green'>and</td><td>( a b -- bool ) Determine if two values are both truthy.</td></tr>
<tr><td class='green'>any?</td><td>( [...] predicate -- bool ) Determine whether any value in a quote passes a condition. Stops at the first truthy result.</td></tr>
<tr><td class='green'>anything?</td><td>( -- bool ) True if any value is present.</td></tr>
<tr><td class='green'>appendf</td><td>( contents filename -- ) Write a string to a file. If a file previously existed, the new content will be appended.</td></tr>
<tr><td class='green'>args</td><td>( -- [arg] ) Produce the arguments provided to the process when it was launched.</td></tr>
<tr><td class='green'>assert-true</td><td>( 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.</td></tr>
<tr><td class='green'>cd</td><td>( dirname -- ) Change the process's working directory.</td></tr>
<tr><td class='green'>chars</td><td>( string -- [substring] ) Splits a string into individual characters, where a character is a single byte. (Not friendly to UTF-8 runes.)</td></tr>
<tr><td class='green'>concat</td><td>( [...] [...] -- [...] ) Concatenate two quotes. Values are coerced into quotes. (For String concatenation, see join.)</td></tr>
<tr><td class='green'>contains?</td><td>( haystack needle -- bool ) With Strings, determine if a string contains a substring. With quotes, determine if a quote contains a value.</td></tr>
<tr><td class='green'>cwd</td><td>( -- dirname ) Produce the current working directory.</td></tr>
<tr><td class='green'>def</td><td>( action name -- ) Define a command.</td></tr>
<tr><td class='green'>def!</td><td>( action name -- ) Defines a new command. If nested, any commands or variables defined will be available in the calling scope.</td></tr>
<tr><td class='green'>def-usage</td><td>( name description -- ) Define the usage notes of a given command.</td></tr>
<tr><td class='green'>def?</td><td>( name -- bool ) Determine whether a command is defined.</td></tr>
<tr><td class='green'>define</td><td>( action description name -- ) Define a command with a description.</td></tr>
<tr><td class='green'>defs</td><td>( -- [name] ) Produce a quote of all defined commands.</td></tr>
<tr><td class='green'>deq</td><td>( [a...] -- a [...] ) Dequeue the first value from a quote.</td></tr>
<tr><td class='green'>divisor?</td><td>( a b -- bool ) Determine if a number a is evenly divisible by number b.</td></tr>
<tr><td class='green'>do</td><td>( ... action -- ... ) Execute an action.</td></tr>
<tr><td class='green'>do!</td><td>( ... action -- ... ) Execute an action. If nested, any commands or variables defined will be available in the calling scope.</td></tr>
<tr><td class='green'>do!?</td><td>( ... action condition -- ... ) Conditionally execute an action. If nested, any commands or variables defined will be available in the calling scope.</td></tr>
<tr><td class='green'>do?</td><td>( ... action condition -- ... ) Conditionally execute an action.</td></tr>
<tr><td class='green'>doin</td><td>( context action -- ) Execute an action in a context.</td></tr>
<tr><td class='green'>downcase</td><td>( string -- lower ) Convert a string to its lowercase form.</td></tr>
<tr><td class='green'>drop</td><td>( a -- ) Drop the most recent value.</td></tr>
<tr><td class='green'>dup</td><td>( a -- a a ) Duplicate the most recent value.</td></tr>
<tr><td class='green'>each</td><td>( [...] action -- ) Perform a given action with each value in a quote.</td></tr>
<tr><td class='green'>ends-with?</td><td>( string suffix -- bool ) Determine if a string ends with a suffix.</td></tr>
<tr><td class='green'>enl</td><td>( -- ) Print a newline to standard error.</td></tr>
<tr><td class='green'>enq</td><td>( a [...] -- [a...] ) Enqueue a value into a quote as its new first value.</td></tr>
<tr><td class='green'>ep</td><td>( a -- ) Print the most recent value to standard error.</td></tr>
<tr><td class='green'>epl</td><td>( a -- ) Print the most recent value and a newline to standard error.</td></tr>
<tr><td class='green'>epls</td><td>( [...] -- ) Print the values of the most recent quote, each followed by a newline, to standard error.</td></tr>
<tr><td class='green'>eprint</td><td>( a -- ) Print the most recent value to standard error.</td></tr>
<tr><td class='green'>eprintln</td><td>( a -- ) Print the most recent value and a newline to standard error.</td></tr>
<tr><td class='green'>eprintlns</td><td>( [...] -- ) Print the values of the most recent quote, each followed by a newline, to standard error.</td></tr>
<tr><td class='green'>eq?</td><td>( a b -- bool ) Determine if two values are equal. Works for most types with coercion.</td></tr>
<tr><td class='green'>eval</td><td>eval</td></tr>
<tr><td class='green'>even?</td><td>( a -- bool ) Determine if a number is even.</td></tr>
<tr><td class='green'>exec</td><td>( 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.</td></tr>
<tr><td class='green'>exit</td><td>( exitcode -- ) Exit with the specified exit code.</td></tr>
<tr><td class='green'>filter</td><td>( [...] predicate -- [...] ) Require some condition of all values in a quote. Truthy results are preserved, and falsy results are not.</td></tr>
<tr><td class='green'>first</td><td>( [a...] -- a ) The first element of a quote.</td></tr>
<tr><td class='green'>green</td><td>( -- ) Print a control character for green and bold (for the colorblind) to standard output and standard error.</td></tr>
<tr><td class='green'>gt?</td><td>( x y -- bool ) Determine if a value is greater than another. In standard notation: a > b</td></tr>
<tr><td class='green'>gte?</td><td>( x y -- bool ) Determine if a value is greater-than/equal-to another. In standard notation: a ≧ b</td></tr>
<tr><td class='green'>help</td><td>( -- ) Print commands and their usage</td></tr>
<tr><td class='green'>inspire</td><td>( -- wisdom ) Get inspiration.</td></tr>
<tr><td class='green'>interactive?</td><td>( -- bool ) Determine if the input mode is interactive (a TTY) or not.</td></tr>
<tr><td class='green'>join</td><td>( [substring] delim -- string ) Join strings with a delimiter.</td></tr>
<tr><td class='green'>last</td><td>( [...a] -- a ) The last element of a quote.</td></tr>
<tr><td class='green'>len</td><td>( [...] -- x ) The length of a string or quote. (Always 1 for single values.)</td></tr>
<tr><td class='green'>lines</td><td>( string -- [substring] ) Splits a string on newlines.</td></tr>
<tr><td class='green'>loop</td><td>( ... action -- ... ) Execute an action forever until it fails.</td></tr>
<tr><td class='green'>ls</td><td>( -- [filename] ) Produce a quote of files and directories in the process's working directory.</td></tr>
<tr><td class='green'>lt?</td><td>( x y -- bool ) Determine if a value is less than another. In standard notation: a < b</td></tr>
<tr><td class='green'>lte?</td><td>( x y -- bool ) Determine if a value is less-than/equal-to another. In standard notation: a ≦ b</td></tr>
<tr><td class='green'>map</td><td>( [...] command -- [...] ) Apply an action to all values in a quote.</td></tr>
<tr><td class='green'>nand</td><td>( a b -- bool ) Determine if two values are not both truthy.</td></tr>
<tr><td class='green'>neq?</td><td>( a b -- bool ) Determine if two values are unequal.</td></tr>
<tr><td class='green'>nl</td><td>( -- ) Print a newline to standard output.</td></tr>
<tr><td class='green'>nor</td><td>( a b -- bool ) Determine if neither of two values are truthy.</td></tr>
<tr><td class='green'>norm</td><td>( -- ) Print a control character to reset any styling to standard output and standard error.</td></tr>
<tr><td class='green'>not</td><td>( a -- bool ) Determine the inverse truthiness of a value.</td></tr>
<tr><td class='green'>odd?</td><td>( a -- bool ) Determine if a number is odd.</td></tr>
<tr><td class='green'>or</td><td>( a b -- bool ) Determine if either of two values are truthy.</td></tr>
<tr><td class='green'>p</td><td>( a -- ) Print the most recent value to standard output.</td></tr>
<tr><td class='green'>parse-csv</td><td>( string -- [[...]] ) Naive conversion of a raw string in comma-separated value (CSV) format to a quote of lines of cells</td></tr>
<tr><td class='green'>pl</td><td>( a -- ) Print the most recent value and a newline to standard output.</td></tr>
<tr><td class='green'>pls</td><td>( [...] -- ) Print the values of the most recent quote, each followed by a newline, to standard output.</td></tr>
<tr><td class='green'>pop</td><td>( [...a] -- [...] a ) Pop the last value from a quote.</td></tr>
<tr><td class='green'>print</td><td>( a -- ) Print the most recent value to standard output.</td></tr>
<tr><td class='green'>println</td><td>( a -- ) Print the most recent value and a newline to standard output.</td></tr>
<tr><td class='green'>printlns</td><td>( [...] -- ) Print the values of the most recent quote, each followed by a newline, to standard output.</td></tr>
<tr><td class='green'>procname</td><td>( -- name ) Produce the name of the current process. This can be used, for example, to get the name of a shebang script.</td></tr>
<tr><td class='green'>push</td><td>( [...] a -- [...a] ) Push a value into a quote as its new last value.</td></tr>
<tr><td class='green'>pwd</td><td>( -- ) Print the current working directory to standard output.</td></tr>
<tr><td class='green'>quit</td><td>( -- ) Quit. Prints a warning if there are any values left on stack.</td></tr>
<tr><td class='green'>quote</td><td>( a -- [a] ) Quote a value.</td></tr>
<tr><td class='green'>quote-all</td><td>( ... -- [...] ) Quote all current context.</td></tr>
<tr><td class='green'>rand</td><td>( -- x ) Produces a random integer.</td></tr>
<tr><td class='green'>read-line</td><td>( -- line ) Read a string from standard input until newline.</td></tr>
<tr><td class='green'>read-lines</td><td>( -- [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.)</td></tr>
<tr><td class='green'>readf</td><td>( filename -- contents ) Read a file's contents as a string.</td></tr>
<tr><td class='green'>readln</td><td>( -- line ) Read a string from standard input until newline.</td></tr>
<tr><td class='green'>readlns</td><td>( -- [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.)</td></tr>
<tr><td class='green'>red</td><td>( -- ) Print a control character for red to standard output and standard error.</td></tr>
<tr><td class='green'>repl</td><td>repl</td></tr>
<tr><td class='green'>rev</td><td>( [...] -- [...] ) Reverse a quote or string. Other types are unmodified.</td></tr>
<tr><td class='green'>rl</td><td>( -- line ) Read a string from standard input until newline.</td></tr>
<tr><td class='green'>rls</td><td>( -- [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.)</td></tr>
<tr><td class='green'>rot</td><td>( a b c -- c a b ) Rotate the three most recent values.</td></tr>
<tr><td class='green'>shebang-args</td><td>shebang-args</td></tr>
<tr><td class='green'>sort</td><td>( [...] -- [...] ) 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.</td></tr>
<tr><td class='green'>split</td><td>( string delim -- [substring] ) Split a string on all occurrences of a delimiter.</td></tr>
<tr><td class='green'>starts-with?</td><td>( string prefix -- bool ) Determine if a string starts with a prefix.</td></tr>
<tr><td class='green'>status</td><td>( -- ) Print the state of the process: all available values.</td></tr>
<tr><td class='green'>swap</td><td>( a b -- b a ) Swap the two most recent values.</td></tr>
<tr><td class='green'>times</td><td>( ... action n -- ... ) Perform a given action n times.</td></tr>
<tr><td class='green'>to-bool</td><td>( a -- bool ) Coerce a value to a boolean.</td></tr>
<tr><td class='green'>to-cmd</td><td>( a -- command ) Coerce a value to a command.</td></tr>
<tr><td class='green'>to-def</td><td>( a -- deferred ) Coerce a value to a deferred command. (Read as "definition" or "deferred".)</td></tr>
<tr><td class='green'>to-float</td><td>( a -- float ) Coerce a value to a floating-point number.</td></tr>
<tr><td class='green'>to-int</td><td>( a -- int ) Coerce a value to an integer.</td></tr>
<tr><td class='green'>to-quote</td><td>( a -- [...] ) Coerce value to a quote. To quote a quote, use quote.</td></tr>
<tr><td class='green'>to-string</td><td>( a -- string ) Coerce a value to a string.</td></tr>
<tr><td class='green'>undef?</td><td>( name -- bool ) Determine whether a command is undefined.</td></tr>
<tr><td class='green'>unlines</td><td>( [substring] -- string ) Joins strings with newlines.</td></tr>
<tr><td class='green'>unquote</td><td>( [...] -- ... ) Unpack a quote.</td></tr>
<tr><td class='green'>unwords</td><td>( [substring] -- string ) Joins strings with spaces.</td></tr>
<tr><td class='green'>upcase</td><td>( string -- upper ) Convert a string to its uppercase form.</td></tr>
<tr><td class='green'>usage</td><td>( name -- description ) Print the usage notes of a given command.</td></tr>
<tr><td class='green'>version</td><td>( -- version ) Produce the version of dt in use.</td></tr>
<tr><td class='green'>while</td><td>( ... action cond -- ... ) Perform an action while the condition is truthy.</td></tr>
<tr><td class='green'>words</td><td>( string -- [substring] ) Splits a string on spaces.</td></tr>
<tr><td class='green'>writef</td><td>( contents filename -- ) Write a string as a file. If a file previously existed, it will be overwritten.</td></tr>
</table>
</main>
</div>
</body>
</html>