miller/docs6/_build/html/reference-dsl.html
2021-05-24 00:11:53 -04:00

4459 lines
No EOL
322 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DSL reference &#8212; Miller 5.10.2 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Manpage" href="manpage.html" />
<link rel="prev" title="Verbs reference" href="reference-verbs.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="manpage.html" title="Manpage"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="reference-verbs.html" title="Verbs reference"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Miller 5.10.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">DSL reference</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="dsl-reference">
<h1>DSL reference<a class="headerlink" href="#dsl-reference" title="Permalink to this headline"></a></h1>
<div class="section" id="overview">
<h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline"></a></h2>
<p>Heres comparison of verbs and <code class="docutils literal notranslate"><span class="pre">put</span></code>/<code class="docutils literal notranslate"><span class="pre">filter</span></code> DSL expressions:</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr stats1 -a sum -f x -g a data/small
a=pan,x_sum=0.346790
a=eks,x_sum=1.140079
a=wye,x_sum=0.777892
</pre></div>
</div>
<ul class="simple">
<li><p>Verbs are coded in C</p></li>
<li><p>They run a bit faster</p></li>
<li><p>They take fewer keystrokes</p></li>
<li><p>There is less to learn</p></li>
<li><p>Their customization is limited to each verbs options</p></li>
</ul>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@x_sum[$a] += $x; end{emit @x_sum, &quot;a&quot;}&#39; data/small
a=pan,x_sum=0.346790
a=eks,x_sum=1.140079
a=wye,x_sum=0.777892
</pre></div>
</div>
<ul class="simple">
<li><p>You get to write your own DSL expressions</p></li>
<li><p>They run a bit slower</p></li>
<li><p>They take more keystrokes</p></li>
<li><p>There is more to learn</p></li>
<li><p>They are highly customizable</p></li>
</ul>
<p>Please see <a class="reference internal" href="reference-verbs.html"><span class="doc">Verbs reference</span></a> for information on verbs other than <code class="docutils literal notranslate"><span class="pre">put</span></code> and <code class="docutils literal notranslate"><span class="pre">filter</span></code>.</p>
<p>The essential usages of <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">filter</span></code> and <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code> are for record-selection and record-updating expressions, respectively. For example, given the following input data:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<p>you might retain only the records whose <code class="docutils literal notranslate"><span class="pre">a</span></code> field has value <code class="docutils literal notranslate"><span class="pre">eks</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr filter &#39;$a == &quot;eks&quot;&#39; data/small
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
</pre></div>
</div>
<p>or you might add a new field which is a function of existing fields:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$ab = $a . &quot;_&quot; . $b &#39; data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533,ab=pan_pan
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797,ab=eks_pan
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776,ab=wye_wye
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463,ab=eks_wye
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729,ab=wye_pan
</pre></div>
</div>
<p>The two verbs <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">filter</span></code> and <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code> are essentially the same. The only differences are:</p>
<ul class="simple">
<li><p>Expressions sent to <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">filter</span></code> must end with a boolean expression, which is the filtering criterion;</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">filter</span></code> expressions may not reference the <code class="docutils literal notranslate"><span class="pre">filter</span></code> keyword within them; and</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">filter</span></code> expressions may not use <code class="docutils literal notranslate"><span class="pre">tee</span></code>, <code class="docutils literal notranslate"><span class="pre">emit</span></code>, <code class="docutils literal notranslate"><span class="pre">emitp</span></code>, or <code class="docutils literal notranslate"><span class="pre">emitf</span></code>.</p></li>
</ul>
<p>All the rest is the same: in particular, you can define and invoke functions and subroutines to help produce the final boolean statement, and record fields may be assigned to in the statements preceding the final boolean statement.</p>
<p>There are more details and more choices, of course, as detailed in the following sections.</p>
</div>
<div class="section" id="syntax">
<h2>Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline"></a></h2>
<div class="section" id="expression-formatting">
<h3>Expression formatting<a class="headerlink" href="#expression-formatting" title="Permalink to this headline"></a></h3>
<p>Multiple expressions may be given, separated by semicolons, and each may refer to the ones before:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ruby -e &#39;10.times{|i|puts &quot;i=#{i}&quot;}&#39; | mlr --opprint put &#39;$j = $i + 1; $k = $i +$j&#39;
i j k
0 1 1
1 2 3
2 3 5
3 4 7
4 5 9
5 6 11
6 7 13
7 8 15
8 9 17
9 10 19
</pre></div>
</div>
<p>Newlines within the expression are ignored, which can help increase legibility of complex expressions:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --opprint put &#39;
$nf = NF;
$nr = NR;
$fnr = FNR;
$filenum = FILENUM;
$filename = FILENAME
&#39; data/small data/small2
a b i x y nf nr fnr filenum filename
pan pan 1 0.3467901443380824 0.7268028627434533 5 1 1 1 data/small
eks pan 2 0.7586799647899636 0.5221511083334797 5 2 2 1 data/small
wye wye 3 0.20460330576630303 0.33831852551664776 5 3 3 1 data/small
eks wye 4 0.38139939387114097 0.13418874328430463 5 4 4 1 data/small
wye pan 5 0.5732889198020006 0.8636244699032729 5 5 5 1 data/small
pan eks 9999 0.267481232652199086 0.557077185510228001 5 6 1 2 data/small2
wye eks 10000 0.734806020620654365 0.884788571337605134 5 7 2 2 data/small2
pan wye 10001 0.870530722602517626 0.009854780514656930 5 8 3 2 data/small2
hat wye 10002 0.321507044286237609 0.568893318795083758 5 9 4 2 data/small2
pan zee 10003 0.272054845593895200 0.425789896597056627 5 10 5 2 data/small2
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --opprint filter &#39;($x &gt; 0.5 &amp;&amp; $y &lt; 0.5) || ($x &lt; 0.5 &amp;&amp; $y &gt; 0.5)&#39; then stats2 -a corr -f x,y data/medium
x_y_corr
-0.747994
</pre></div>
</div>
</div>
<div class="section" id="expressions-from-files">
<span id="reference-dsl-expressions-from-files"></span><h3>Expressions from files<a class="headerlink" href="#expressions-from-files" title="Permalink to this headline"></a></h3>
<p>The simplest way to enter expressions for <code class="docutils literal notranslate"><span class="pre">put</span></code> and <code class="docutils literal notranslate"><span class="pre">filter</span></code> is between single quotes on the command line, e.g.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small put &#39;$xy = sqrt($x**2 + $y**2)&#39;
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533,xy=0.805299
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797,xy=0.920998
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776,xy=0.395376
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463,xy=0.404317
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729,xy=1.036584
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small put &#39;func f(a, b) { return sqrt(a**2 + b**2) } $xy = f($x, $y)&#39;
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533,xy=0.805299
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797,xy=0.920998
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776,xy=0.395376
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463,xy=0.404317
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729,xy=1.036584
</pre></div>
</div>
<p>You may, though, find it convenient to put expressions into files for reuse, and read them
<strong>using the -f option</strong>. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/fe-example-3.mlr
func f(a, b) {
return sqrt(a**2 + b**2)
}
$xy = f($x, $y)
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small put -f data/fe-example-3.mlr
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533,xy=0.805299
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797,xy=0.920998
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776,xy=0.395376
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463,xy=0.404317
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729,xy=1.036584
</pre></div>
</div>
<p>If you have some of the logic in a file and you want to write the rest on the command line, you can <strong>use the -f and -e options together</strong>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/fe-example-4.mlr
func f(a, b) {
return sqrt(a**2 + b**2)
}
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small put -f data/fe-example-4.mlr -e &#39;$xy = f($x, $y)&#39;
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533,xy=0.805299
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797,xy=0.920998
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776,xy=0.395376
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463,xy=0.404317
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729,xy=1.036584
</pre></div>
</div>
<p>A suggested use-case here is defining functions in files, and calling them from command-line expressions.</p>
<p>Another suggested use-case is putting default parameter values in files, e.g. using <code class="docutils literal notranslate"><span class="pre">begin{&#64;count=is_present(&#64;count)?&#64;count:10}</span></code> in the file, where you can precede that using <code class="docutils literal notranslate"><span class="pre">begin{&#64;count=40}</span></code> using <code class="docutils literal notranslate"><span class="pre">-e</span></code>.</p>
<p>Moreover, you can have one or more <code class="docutils literal notranslate"><span class="pre">-f</span></code> expressions (maybe one function per file, for example) and one or more <code class="docutils literal notranslate"><span class="pre">-e</span></code> expressions on the command line. If you mix <code class="docutils literal notranslate"><span class="pre">-f</span></code> and <code class="docutils literal notranslate"><span class="pre">-e</span></code> then the expressions are evaluated in the order encountered. (Since the expressions are all simply concatenated together in order, dont forget intervening semicolons: e.g. not <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span> <span class="pre">-e</span> <span class="pre">'$x=1'</span> <span class="pre">-e</span> <span class="pre">'$y=2</span> <span class="pre">...'</span></code> but rather <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span> <span class="pre">-e</span> <span class="pre">'$x=1;'</span> <span class="pre">-e</span> <span class="pre">'$y=2'</span> <span class="pre">...</span></code>.)</p>
</div>
<div class="section" id="semicolons-commas-newlines-and-curly-braces">
<h3>Semicolons, commas, newlines, and curly braces<a class="headerlink" href="#semicolons-commas-newlines-and-curly-braces" title="Permalink to this headline"></a></h3>
<p>Miller uses <strong>semicolons as statement separators</strong>, not statement terminators. This means you can write:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;x=1&#39;</span>
<span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;x=1;$y=2&#39;</span>
<span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;x=1;$y=2;&#39;</span>
<span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;x=1;;;;$y=2;&#39;</span>
</pre></div>
</div>
<p>Semicolons are optional after closing curly braces (which close conditionals and loops as discussed below).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ echo x=1,y=2 | mlr put &#39;while (NF &lt; 10) { $[NF+1] = &quot;&quot;} $foo = &quot;bar&quot;&#39;
x=1,y=2,3=,4=,5=,6=,7=,8=,9=,10=,foo=bar
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ echo x=1,y=2 | mlr put &#39;while (NF &lt; 10) { $[NF+1] = &quot;&quot;}; $foo = &quot;bar&quot;&#39;
x=1,y=2,3=,4=,5=,6=,7=,8=,9=,10=,foo=bar
</pre></div>
</div>
<p>Semicolons are required between statements even if those statements are on separate lines. <strong>Newlines</strong> are for your convenience but have no syntactic meaning: line endings do not terminate statements. For example, adjacent assignment statements must be separated by semicolons even if those statements are on separate lines:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>mlr put &#39;
$x = 1
$y = 2 # Syntax error
&#39;
mlr put &#39;
$x = 1;
$y = 2 # This is OK
&#39;
</pre></div>
</div>
<p><strong>Trailing commas</strong> are allowed in function/subroutine definitions, function/subroutine callsites, and map literals. This is intended for (although not restricted to) the multi-line case:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --csvlite --from data/a.csv put &#39;
func f(
num a,
num b,
): num {
return a**2 + b**2;
}
$* = {
&quot;s&quot;: $a + $b,
&quot;t&quot;: $a - $b,
&quot;u&quot;: f(
$a,
$b,
),
&quot;v&quot;: NR,
}
&#39;
s,t,u,v
3,-1,5.000000,1
9,-1,41.000000,2
</pre></div>
</div>
<p>Bodies for all compound statements must be enclosed in <strong>curly braces</strong>, even if the body is a single statement:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;if ($x == 1) $y = 2&#39;</span> <span class="c1"># Syntax error</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;if ($x == 1) { $y = 2 }&#39;</span> <span class="c1"># This is OK</span>
</pre></div>
</div>
<p>Bodies for compound statements may be empty:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;if ($x == 1) { }&#39;</span> <span class="c1"># This no-op is syntactically acceptable</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="variables">
<h2>Variables<a class="headerlink" href="#variables" title="Permalink to this headline"></a></h2>
<p>Miller has the following kinds of variables:</p>
<p><strong>Built-in variables</strong> such as <code class="docutils literal notranslate"><span class="pre">NF</span></code>, <code class="docutils literal notranslate"><span class="pre">NF</span></code>, <code class="docutils literal notranslate"><span class="pre">FILENAME</span></code>, <code class="docutils literal notranslate"><span class="pre">M_PI</span></code>, and <code class="docutils literal notranslate"><span class="pre">M_E</span></code>. These are all capital letters and are read-only (although some of them change value from one record to another).</p>
<p><strong>Fields of stream records</strong>, accessed using the <code class="docutils literal notranslate"><span class="pre">$</span></code> prefix. These refer to fields of the current data-stream record. For example, in <code class="docutils literal notranslate"><span class="pre">echo</span> <span class="pre">x=1,y=2</span> <span class="pre">|</span> <span class="pre">mlr</span> <span class="pre">put</span> <span class="pre">'$z</span> <span class="pre">=</span> <span class="pre">$x</span> <span class="pre">+</span> <span class="pre">$y'</span></code>, <code class="docutils literal notranslate"><span class="pre">$x</span></code> and <code class="docutils literal notranslate"><span class="pre">$y</span></code> refer to input fields, and <code class="docutils literal notranslate"><span class="pre">$z</span></code> refers to a new, computed output field. In a few contexts, presented below, you can refer to the entire record as <code class="docutils literal notranslate"><span class="pre">$*</span></code>.</p>
<p><strong>Out-of-stream variables</strong> accessed using the <code class="docutils literal notranslate"><span class="pre">&#64;</span></code> prefix. These refer to data which persist from one record to the next, including in <code class="docutils literal notranslate"><span class="pre">begin</span></code> and <code class="docutils literal notranslate"><span class="pre">end</span></code> blocks (which execute before/after the record stream is consumed, respectively). You use them to remember values across records, such as sums, differences, counters, and so on. In a few contexts, presented below, you can refer to the entire out-of-stream-variables collection as <code class="docutils literal notranslate"><span class="pre">&#64;*</span></code>.</p>
<p><strong>Local variables</strong> are limited in scope and extent to the current statements being executed: these include function arguments, bound variables in for loops, and explicitly declared local variables.</p>
<p><strong>Keywords</strong> are not variables, but since their names are reserved, you cannot use these names for local variables.</p>
<div class="section" id="built-in-variables">
<h3>Built-in variables<a class="headerlink" href="#built-in-variables" title="Permalink to this headline"></a></h3>
<p>These are written all in capital letters, such as <code class="docutils literal notranslate"><span class="pre">NR</span></code>, <code class="docutils literal notranslate"><span class="pre">NF</span></code>, <code class="docutils literal notranslate"><span class="pre">FILENAME</span></code>, and only a small, specific set of them is defined by Miller.</p>
<p>Namely, Miller supports the following five built-in variables for <a class="reference internal" href="#"><span class="doc">filter and put</span></a>, all <code class="docutils literal notranslate"><span class="pre">awk</span></code>-inspired: <code class="docutils literal notranslate"><span class="pre">NF</span></code>, <code class="docutils literal notranslate"><span class="pre">NR</span></code>, <code class="docutils literal notranslate"><span class="pre">FNR</span></code>, <code class="docutils literal notranslate"><span class="pre">FILENUM</span></code>, and <code class="docutils literal notranslate"><span class="pre">FILENAME</span></code>, as well as the mathematical constants <code class="docutils literal notranslate"><span class="pre">M_PI</span></code> and <code class="docutils literal notranslate"><span class="pre">M_E</span></code>. Lastly, the <code class="docutils literal notranslate"><span class="pre">ENV</span></code> hashmap allows read access to environment variables, e.g. <code class="docutils literal notranslate"><span class="pre">ENV[&quot;HOME&quot;]</span></code> or <code class="docutils literal notranslate"><span class="pre">ENV[&quot;foo_&quot;.$hostname]</span></code>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr filter &#39;FNR == 2&#39; data/small*
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
1=pan,2=pan,3=1,4=0.3467901443380824,5=0.7268028627434533
a=wye,b=eks,i=10000,x=0.734806020620654365,y=0.884788571337605134
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$fnr = FNR&#39; data/small*
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533,fnr=1
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797,fnr=2
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776,fnr=3
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463,fnr=4
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729,fnr=5
1=a,2=b,3=i,4=x,5=y,fnr=1
1=pan,2=pan,3=1,4=0.3467901443380824,5=0.7268028627434533,fnr=2
1=eks,2=pan,3=2,4=0.7586799647899636,5=0.5221511083334797,fnr=3
1=wye,2=wye,3=3,4=0.20460330576630303,5=0.33831852551664776,fnr=4
1=eks,2=wye,3=4,4=0.38139939387114097,5=0.13418874328430463,fnr=5
1=wye,2=pan,3=5,4=0.5732889198020006,5=0.8636244699032729,fnr=6
a=pan,b=eks,i=9999,x=0.267481232652199086,y=0.557077185510228001,fnr=1
a=wye,b=eks,i=10000,x=0.734806020620654365,y=0.884788571337605134,fnr=2
a=pan,b=wye,i=10001,x=0.870530722602517626,y=0.009854780514656930,fnr=3
a=hat,b=wye,i=10002,x=0.321507044286237609,y=0.568893318795083758,fnr=4
a=pan,b=zee,i=10003,x=0.272054845593895200,y=0.425789896597056627,fnr=5
</pre></div>
</div>
<p>Their values of <code class="docutils literal notranslate"><span class="pre">NF</span></code>, <code class="docutils literal notranslate"><span class="pre">NR</span></code>, <code class="docutils literal notranslate"><span class="pre">FNR</span></code>, <code class="docutils literal notranslate"><span class="pre">FILENUM</span></code>, and <code class="docutils literal notranslate"><span class="pre">FILENAME</span></code> change from one record to the next as Miller scans through your input data stream. The mathematical constants, of course, do not change; <code class="docutils literal notranslate"><span class="pre">ENV</span></code> is populated from the system environment variables at the time Miller starts and is read-only for the remainder of program execution.</p>
<p>Their <strong>scope is global</strong>: you can refer to them in any <code class="docutils literal notranslate"><span class="pre">filter</span></code> or <code class="docutils literal notranslate"><span class="pre">put</span></code> statement. Their values are assigned by the input-record reader:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --csv put &#39;$nr = NR&#39; data/a.csv
a,b,c,nr
1,2,3,1
4,5,6,2
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --csv repeat -n 3 then put &#39;$nr = NR&#39; data/a.csv
a,b,c,nr
1,2,3,1
1,2,3,1
1,2,3,1
4,5,6,2
4,5,6,2
4,5,6,2
</pre></div>
</div>
<p>The <strong>extent</strong> is for the duration of the put/filter: in a <code class="docutils literal notranslate"><span class="pre">begin</span></code> statement (which executes before the first input record is consumed) you will find <code class="docutils literal notranslate"><span class="pre">NR=1</span></code> and in an <code class="docutils literal notranslate"><span class="pre">end</span></code> statement (which is executed after the last input record is consumed) you will find <code class="docutils literal notranslate"><span class="pre">NR</span></code> to be the total number of records ingested.</p>
<p>These are all <strong>read-only</strong> for the <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code> and <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">filter</span></code> DSLs: they may be assigned from, e.g. <code class="docutils literal notranslate"><span class="pre">$nr=NR</span></code>, but they may not be assigned to: <code class="docutils literal notranslate"><span class="pre">NR=100</span></code> is a syntax error.</p>
</div>
<div class="section" id="field-names">
<h3>Field names<a class="headerlink" href="#field-names" title="Permalink to this headline"></a></h3>
<p>Names of fields within stream records must be specified using a <code class="docutils literal notranslate"><span class="pre">$</span></code> in <a class="reference internal" href="#"><span class="doc">filter and put expressions</span></a>, even though the dollar signs dont appear in the data stream itself. For integer-indexed data, this looks like <code class="docutils literal notranslate"><span class="pre">awk</span></code>s <code class="docutils literal notranslate"><span class="pre">$1,$2,$3</span></code>, except that Miller allows non-numeric names such as <code class="docutils literal notranslate"><span class="pre">$quantity</span></code> or <code class="docutils literal notranslate"><span class="pre">$hostname</span></code>. Likewise, enclose string literals in double quotes in <code class="docutils literal notranslate"><span class="pre">filter</span></code> expressions even though they dont appear in file data. In particular, <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">filter</span> <span class="pre">'$x==&quot;abc&quot;'</span></code> passes through the record <code class="docutils literal notranslate"><span class="pre">x=abc</span></code>.</p>
<p>If field names have <strong>special characters</strong> such as <code class="docutils literal notranslate"><span class="pre">.</span></code> then you can use braces, e.g. <code class="docutils literal notranslate"><span class="pre">'${field.name}'</span></code>.</p>
<p>You may also use a <strong>computed field name</strong> in square brackets, e.g.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ echo a=3,b=4 | mlr filter &#39;$[&quot;x&quot;] &lt; 0.5&#39;
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ echo s=green,t=blue,a=3,b=4 | mlr put &#39;$[$s.&quot;_&quot;.$t] = $a * $b&#39;
s=green,t=blue,a=3,b=4,green_blue=12
</pre></div>
</div>
<p>Notes:</p>
<p>The names of record fields depend on the contents of your input data stream, and their values change from one record to the next as Miller scans through your input data stream.</p>
<p>Their <strong>extent</strong> is limited to the current record; their <strong>scope</strong> is the <code class="docutils literal notranslate"><span class="pre">filter</span></code> or <code class="docutils literal notranslate"><span class="pre">put</span></code> command in which they appear.</p>
<p>These are <strong>read-write</strong>: you can do <code class="docutils literal notranslate"><span class="pre">$y=2*$x</span></code>, <code class="docutils literal notranslate"><span class="pre">$x=$x+1</span></code>, etc.</p>
<p>Records are Millers output: field names present in the input stream are passed through to output (written to standard output) unless fields are removed with <code class="docutils literal notranslate"><span class="pre">cut</span></code>, or records are excluded with <code class="docutils literal notranslate"><span class="pre">filter</span></code> or <code class="docutils literal notranslate"><span class="pre">put</span> <span class="pre">-q</span></code>, etc. Simply assign a value to a field and it will be output.</p>
</div>
<div class="section" id="positional-field-names">
<h3>Positional field names<a class="headerlink" href="#positional-field-names" title="Permalink to this headline"></a></h3>
<p>Even though Millers main selling point is name-indexing, sometimes you really want to refer to a field name by its positional index (starting from 1).</p>
<p>Use <code class="docutils literal notranslate"><span class="pre">$[[3]]</span></code> to access the name of field 3. More generally, any expression evaluating to an integer can go between <code class="docutils literal notranslate"><span class="pre">$[[</span></code> and <code class="docutils literal notranslate"><span class="pre">]]</span></code>.</p>
<p>Then using a computed field name, <code class="docutils literal notranslate"><span class="pre">$[</span> <span class="pre">$[[3]]</span> <span class="pre">]</span></code> is the value in the third field. This has the shorter equivalent notation <code class="docutils literal notranslate"><span class="pre">$[[[3]]]</span></code>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr cat data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$[[3]] = &quot;NEW&quot;&#39; data/small
a=pan,b=pan,NEW=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,NEW=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,NEW=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,NEW=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,NEW=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$[[[3]]] = &quot;NEW&quot;&#39; data/small
a=pan,b=pan,i=NEW,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=NEW,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=NEW,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=NEW,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=NEW,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$NEW = $[[NR]]&#39; data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533,NEW=a
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797,NEW=b
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776,NEW=i
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463,NEW=x
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729,NEW=y
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$NEW = $[[[NR]]]&#39; data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533,NEW=pan
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797,NEW=pan
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776,NEW=3
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463,NEW=0.381399
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729,NEW=0.863624
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$[[[NR]]] = &quot;NEW&quot;&#39; data/small
a=NEW,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=NEW,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=NEW,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=NEW,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=NEW
</pre></div>
</div>
<p>Right-hand side accesses to non-existent fields i.e. with index less than 1 or greater than <code class="docutils literal notranslate"><span class="pre">NF</span></code> return an absent value. Likewise, left-hand side accesses only refer to fields which already exist. For example, if a field has 5 records then assigning the name or value of the 6th (or 600th) field results in a no-op.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$[[6]] = &quot;NEW&quot;&#39; data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$[[[6]]] = &quot;NEW&quot;&#39; data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
</div>
<div class="section" id="out-of-stream-variables">
<h3>Out-of-stream variables<a class="headerlink" href="#out-of-stream-variables" title="Permalink to this headline"></a></h3>
<p>These are prefixed with an at-sign, e.g. <code class="docutils literal notranslate"><span class="pre">&#64;sum</span></code>. Furthermore, unlike built-in variables and stream-record fields, they are maintained in an arbitrarily nested hashmap: you can do <code class="docutils literal notranslate"><span class="pre">&#64;sum</span> <span class="pre">+=</span> <span class="pre">$quanity</span></code>, or <code class="docutils literal notranslate"><span class="pre">&#64;sum[$color]</span> <span class="pre">+=</span> <span class="pre">$quanity</span></code>, or <code class="docutils literal notranslate"><span class="pre">&#64;sum[$color][$shape]</span> <span class="pre">+=</span> <span class="pre">$quanity</span></code>. The keys for the multi-level hashmap can be any expression which evaluates to string or integer: e.g. <code class="docutils literal notranslate"><span class="pre">&#64;sum[NR]</span> <span class="pre">=</span> <span class="pre">$a</span> <span class="pre">+</span> <span class="pre">$b</span></code>, <code class="docutils literal notranslate"><span class="pre">&#64;sum[$a.&quot;-&quot;.$b]</span> <span class="pre">=</span> <span class="pre">$x</span></code>, etc.</p>
<p>Their names and their values are entirely under your control; they change only when you assign to them.</p>
<p>Just as for field names in stream records, if you want to define out-of-stream variables with <strong>special characters</strong> such as <code class="docutils literal notranslate"><span class="pre">.</span></code> then you can use braces, e.g. <code class="docutils literal notranslate"><span class="pre">'&#64;{variable.name}[&quot;index&quot;]'</span></code>.</p>
<p>You may use a <strong>computed key</strong> in square brackets, e.g.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ echo s=green,t=blue,a=3,b=4 | mlr put -q &#39;@[$s.&quot;_&quot;.$t] = $a * $b; emit all&#39;
green_blue=12
</pre></div>
</div>
<p>Out-of-stream variables are <strong>scoped</strong> to the <code class="docutils literal notranslate"><span class="pre">put</span></code> command in which they appear. In particular, if you have two or more <code class="docutils literal notranslate"><span class="pre">put</span></code> commands separated by <code class="docutils literal notranslate"><span class="pre">then</span></code>, each put will have its own set of out-of-stream variables:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/a.dkvp
a=1,b=2,c=3
a=4,b=5,c=6
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;@sum += $a; end {emit @sum}&#39; then put &#39;is_present($a) {$a=10*$a; @sum += $a}; end {emit @sum}&#39; data/a.dkvp
a=10,b=2,c=3
a=40,b=5,c=6
sum=5
sum=50
</pre></div>
</div>
<p>Out-of-stream variables <strong>extent</strong> is from the start to the end of the record stream, i.e. every time the <code class="docutils literal notranslate"><span class="pre">put</span></code> or <code class="docutils literal notranslate"><span class="pre">filter</span></code> statement referring to them is executed.</p>
<p>Out-of-stream variables are <strong>read-write</strong>: you can do <code class="docutils literal notranslate"><span class="pre">$sum=&#64;sum</span></code>, <code class="docutils literal notranslate"><span class="pre">&#64;sum=$sum</span></code>, etc.</p>
</div>
<div class="section" id="indexed-out-of-stream-variables">
<h3>Indexed out-of-stream variables<a class="headerlink" href="#indexed-out-of-stream-variables" title="Permalink to this headline"></a></h3>
<p>Using an index on the <code class="docutils literal notranslate"><span class="pre">&#64;count</span></code> and <code class="docutils literal notranslate"><span class="pre">&#64;sum</span></code> variables, we get the benefit of the <code class="docutils literal notranslate"><span class="pre">-g</span></code> (group-by) option which <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">stats1</span></code> and various other Miller commands have:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;
@x_count[$a] += 1;
@x_sum[$a] += $x;
end {
emit @x_count, &quot;a&quot;;
emit @x_sum, &quot;a&quot;;
}
&#39; ../data/small
a=pan,x_count=2
a=eks,x_count=3
a=wye,x_count=2
a=zee,x_count=2
a=hat,x_count=1
a=pan,x_sum=0.849416
a=eks,x_sum=1.751863
a=wye,x_sum=0.777892
a=zee,x_sum=1.125680
a=hat,x_sum=0.031442
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr stats1 -a count,sum -f x -g a ../data/small
a=pan,x_count=2,x_sum=0.849416
a=eks,x_count=3,x_sum=1.751863
a=wye,x_count=2,x_sum=0.777892
a=zee,x_count=2,x_sum=1.125680
a=hat,x_count=1,x_sum=0.031442
</pre></div>
</div>
<p>Indices can be arbitrarily deep here there are two or more of them:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/medium put -q &#39;
@x_count[$a][$b] += 1;
@x_sum[$a][$b] += $x;
end {
emit (@x_count, @x_sum), &quot;a&quot;, &quot;b&quot;;
}
&#39;
a=pan,b=pan,x_count=427,x_sum=219.185129
a=pan,b=wye,x_count=395,x_sum=198.432931
a=pan,b=eks,x_count=429,x_sum=216.075228
a=pan,b=hat,x_count=417,x_sum=205.222776
a=pan,b=zee,x_count=413,x_sum=205.097518
a=eks,b=pan,x_count=371,x_sum=179.963030
a=eks,b=wye,x_count=407,x_sum=196.945286
a=eks,b=zee,x_count=357,x_sum=176.880365
a=eks,b=eks,x_count=413,x_sum=215.916097
a=eks,b=hat,x_count=417,x_sum=208.783171
a=wye,b=wye,x_count=377,x_sum=185.295850
a=wye,b=pan,x_count=392,x_sum=195.847900
a=wye,b=hat,x_count=426,x_sum=212.033183
a=wye,b=zee,x_count=385,x_sum=194.774048
a=wye,b=eks,x_count=386,x_sum=204.812961
a=zee,b=pan,x_count=389,x_sum=202.213804
a=zee,b=wye,x_count=455,x_sum=233.991394
a=zee,b=eks,x_count=391,x_sum=190.961778
a=zee,b=zee,x_count=403,x_sum=206.640635
a=zee,b=hat,x_count=409,x_sum=191.300006
a=hat,b=wye,x_count=423,x_sum=208.883010
a=hat,b=zee,x_count=385,x_sum=196.349450
a=hat,b=eks,x_count=389,x_sum=189.006793
a=hat,b=hat,x_count=381,x_sum=182.853532
a=hat,b=pan,x_count=363,x_sum=168.553807
</pre></div>
</div>
<p>The idea is that <code class="docutils literal notranslate"><span class="pre">stats1</span></code>, and other Miller verbs, encapsulate frequently-used patterns with a minimum of keystroking (and run a little faster), whereas using out-of-stream variables you have more flexibility and control in what you do.</p>
<p>Begin/end blocks can be mixed with pattern/action blocks. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;
begin {
@num_total = 0;
@num_positive = 0;
};
@num_total += 1;
$x &gt; 0.0 {
@num_positive += 1;
$y = log10($x); $z = sqrt($y)
};
end {
emitf @num_total, @num_positive
}
&#39; data/put-gating-example-1.dkvp
x=-1
x=0
x=1,y=0.000000,z=0.000000
x=2,y=0.301030,z=0.548662
x=3,y=0.477121,z=0.690740
num_total=5,num_positive=3
</pre></div>
</div>
</div>
<div class="section" id="local-variables">
<span id="reference-dsl-local-variables"></span><h3>Local variables<a class="headerlink" href="#local-variables" title="Permalink to this headline"></a></h3>
<p>Local variables are similar to out-of-stream variables, except that their extent is limited to the expressions in which they appear (and their basenames cant be computed using square brackets). There are three kinds of local variables: <strong>arguments</strong> to functions/subroutines, <strong>variables bound within for-loops</strong>, and <strong>locals</strong> defined within control blocks. They may be untyped using <code class="docutils literal notranslate"><span class="pre">var</span></code>, or typed using <code class="docutils literal notranslate"><span class="pre">num</span></code>, <code class="docutils literal notranslate"><span class="pre">int</span></code>, <code class="docutils literal notranslate"><span class="pre">float</span></code>, <code class="docutils literal notranslate"><span class="pre">str</span></code>, <code class="docutils literal notranslate"><span class="pre">bool</span></code>, and <code class="docutils literal notranslate"><span class="pre">map</span></code>.</p>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ # Here I&#39;m using a specified random-number seed so this example always
# produces the same output for this web document: in everyday practice we
# would leave off the --seed 12345 part.
mlr --seed 12345 seqgen --start 1 --stop 10 then put &#39;
func f(a, b) { # function arguments a and b
r = 0.0; # local r scoped to the function
for (int i = 0; i &lt; 6; i += 1) { # local i scoped to the for-loop
num u = urand(); # local u scoped to the for-loop
r += u; # updates r from the enclosing scope
}
r /= 6;
return a + (b - a) * r;
}
num o = f(10, 20); # local to the top-level scope
$o = o;
&#39;
i=1,o=14.662901
i=2,o=17.881983
i=3,o=14.586560
i=4,o=16.402409
i=5,o=16.336598
i=6,o=14.622701
i=7,o=15.983753
i=8,o=13.852177
i=9,o=15.472899
i=10,o=15.643912
</pre></div>
</div>
<p>Things which are completely unsurprising, resembling many other languages:</p>
<ul class="simple">
<li><p>Parameter names are bound to their arguments but can be reassigned, e.g. if there is a parameter named <code class="docutils literal notranslate"><span class="pre">a</span></code> then you can reassign the value of <code class="docutils literal notranslate"><span class="pre">a</span></code> to be something else within the function if you like.</p></li>
<li><p>However, you cannot redeclare the <em>type</em> of an argument or a local: <code class="docutils literal notranslate"><span class="pre">var</span> <span class="pre">a=1;</span> <span class="pre">var</span> <span class="pre">a=2</span></code> is an error but <code class="docutils literal notranslate"><span class="pre">var</span> <span class="pre">a=1;</span>&#160; <span class="pre">a=2</span></code> is OK.</p></li>
<li><p>All argument-passing is positional rather than by name; arguments are passed by value, not by reference. (This is also true for map-valued variables: they are not, and cannot be, passed by reference)</p></li>
<li><p>You can define locals (using <code class="docutils literal notranslate"><span class="pre">var</span></code>, <code class="docutils literal notranslate"><span class="pre">num</span></code>, etc.) at any scope (if-statements, else-statements, while-loops, for-loops, or the top-level scope), and nested scopes will have access (more details on scope in the next section). If you define a local variable with the same name inside an inner scope, then a new variable is created with the narrower scope.</p></li>
<li><p>If you assign to a local variable for the first time in a scope without declaring it as <code class="docutils literal notranslate"><span class="pre">var</span></code>, <code class="docutils literal notranslate"><span class="pre">num</span></code>, etc. then: if it exists in an outer scope, that outer-scope variable will be updated; if not, it will be defined in the current scope as if <code class="docutils literal notranslate"><span class="pre">var</span></code> had been used. (See also <a class="reference internal" href="#reference-dsl-type-checking"><span class="std std-ref">Type-checking</span></a> for an example.) I recommend always declaring variables explicitly to make the intended scoping clear.</p></li>
<li><p>Functions and subroutines never have access to locals from their callee (unless passed by value as arguments).</p></li>
</ul>
<p>Things which are perhaps surprising compared to other languages:</p>
<ul class="simple">
<li><p>Type declarations using <code class="docutils literal notranslate"><span class="pre">var</span></code>, or typed using <code class="docutils literal notranslate"><span class="pre">num</span></code>, <code class="docutils literal notranslate"><span class="pre">int</span></code>, <code class="docutils literal notranslate"><span class="pre">float</span></code>, <code class="docutils literal notranslate"><span class="pre">str</span></code>, and <code class="docutils literal notranslate"><span class="pre">bool</span></code> are necessary to declare local variables. Function arguments and variables bound in for-loops over stream records and out-of-stream variables are <em>implicitly</em> declared using <code class="docutils literal notranslate"><span class="pre">var</span></code>. (Some examples are shown below.)</p></li>
<li><p>Type-checking is done at assignment time. For example, <code class="docutils literal notranslate"><span class="pre">float</span> <span class="pre">f</span> <span class="pre">=</span> <span class="pre">0</span></code> is an error (since <code class="docutils literal notranslate"><span class="pre">0</span></code> is an integer), as is <code class="docutils literal notranslate"><span class="pre">float</span> <span class="pre">f</span> <span class="pre">=</span> <span class="pre">0.0;</span> <span class="pre">f</span> <span class="pre">=</span> <span class="pre">1</span></code>. For this reason I prefer to use <code class="docutils literal notranslate"><span class="pre">num</span></code> over <code class="docutils literal notranslate"><span class="pre">float</span></code> in most contexts since <code class="docutils literal notranslate"><span class="pre">num</span></code> encompasses integer and floating-point values. More information about type-checking is at <a class="reference internal" href="#reference-dsl-type-checking"><span class="std std-ref">Type-checking</span></a>.</p></li>
<li><p>Bound variables in for-loops over stream records and out-of-stream variables are implicitly local to that block. E.g. in <code class="docutils literal notranslate"><span class="pre">for</span> <span class="pre">(k,</span> <span class="pre">v</span> <span class="pre">in</span> <span class="pre">$*)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">}</span></code> <code class="docutils literal notranslate"><span class="pre">for</span> <span class="pre">((k1,</span> <span class="pre">k2),</span> <span class="pre">v</span> <span class="pre">in</span> <span class="pre">&#64;*)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">}</span></code> if there are <code class="docutils literal notranslate"><span class="pre">k</span></code>, <code class="docutils literal notranslate"><span class="pre">v</span></code>, etc. in the enclosing scope then those will be masked by the loop-local bound variables in the loop, and moreover the values of the loop-local bound variables are not available after the end of the loop.</p></li>
<li><p>For C-style triple-for loops, if a for-loop variable is defined using <code class="docutils literal notranslate"><span class="pre">var</span></code>, <code class="docutils literal notranslate"><span class="pre">int</span></code>, etc. then it is scoped to that for-loop. E.g. <code class="docutils literal notranslate"><span class="pre">for</span> <span class="pre">(i</span> <span class="pre">=</span> <span class="pre">0;</span> <span class="pre">i</span> <span class="pre">&lt;</span> <span class="pre">10;</span> <span class="pre">i</span> <span class="pre">+=</span> <span class="pre">1)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">}</span></code> and <code class="docutils literal notranslate"><span class="pre">for</span> <span class="pre">(int</span> <span class="pre">i</span> <span class="pre">=</span> <span class="pre">0;</span> <span class="pre">i</span> <span class="pre">&lt;</span> <span class="pre">10;</span> <span class="pre">i</span> <span class="pre">+=</span> <span class="pre">1)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">}</span></code>. (This is unsurprising.). If there is no typedecl and an outer-scope variable of that name exists, then it is used. (This is also unsurprising.) But of there is no outer-scope variable of that name then the variable is scoped to the for-loop only.</p></li>
</ul>
<p>The following example demonstrates the scope rules:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/scope-example.mlr
func f(a) { # argument is local to the function
var b = 100; # local to the function
c = 100; # local to the function; does not overwrite outer c
return a + 1;
}
var a = 10; # local at top level
var b = 20; # local at top level
c = 30; # local at top level; there is no more-outer-scope c
if (NR == 3) {
var a = 40; # scoped to the if-statement; doesn&#39;t overwrite outer a
b = 50; # not scoped to the if-statement; overwrites outer b
c = 60; # not scoped to the if-statement; overwrites outer c
d = 70; # there is no outer d so a local d is created here
$inner_a = a;
$inner_b = b;
$inner_c = c;
$inner_d = d;
}
$outer_a = a;
$outer_b = b;
$outer_c = c;
$outer_d = d; # there is no outer d defined so no assignment happens
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/scope-example.dat
n=1,x=123
n=2,x=456
n=3,x=789
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --oxtab --from data/scope-example.dat put -f data/scope-example.mlr
n 1
x 123
outer_a 10
outer_b 20
outer_c 30
n 2
x 456
outer_a 10
outer_b 20
outer_c 30
n 3
x 789
inner_a 40
inner_b 50
inner_c 60
inner_d 70
outer_a 10
outer_b 50
outer_c 60
</pre></div>
</div>
<p>And this example demonstrates the type-declaration rules:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/type-decl-example.mlr
subr s(a, str b, int c) { # a is implicitly var (untyped).
# b is explicitly str.
# c is explicitly int.
# The type-checking is done at the callsite
# when arguments are bound to parameters.
#
var b = 100; # error # Re-declaration in the same scope is disallowed.
int n = 10; # Declaration of variable local to the subroutine.
n = 20; # Assignment is OK.
int n = 30; # error # Re-declaration in the same scope is disallowed.
str n = &quot;abc&quot;; # error # Re-declaration in the same scope is disallowed.
#
float f1 = 1; # error # 1 is an int, not a float.
float f2 = 2.0; # 2.0 is a float.
num f3 = 3; # 3 is a num.
num f4 = 4.0; # 4.0 is a num.
} #
#
call s(1, 2, 3); # Type-assertion &#39;3 is int&#39; is done here at the callsite.
#
k = &quot;def&quot;; # Top-level variable k.
#
for (str k, v in $*) { # k and v are bound here, masking outer k.
print k . &quot;:&quot; . v; # k is explicitly str; v is implicitly var.
} #
#
print &quot;k is&quot;.k; # k at this scope level is still &quot;def&quot;.
print &quot;v is&quot;.v; # v is undefined in this scope.
#
i = -1; #
for (i = 1, int j = 2; i &lt;= 10; i += 1, j *= 2) { # C-style triple-for variables use enclosing scope, unless
# declared local: i is outer, j is local to the loop.
print &quot;inner i =&quot; . i; #
print &quot;inner j =&quot; . j; #
} #
print &quot;outer i =&quot; . i; # i has been modified by the loop.
print &quot;outer j =&quot; . j; # j is undefined in this scope.
</pre></div>
</div>
</div>
<div class="section" id="map-literals">
<h3>Map literals<a class="headerlink" href="#map-literals" title="Permalink to this headline"></a></h3>
<p>Millers <code class="docutils literal notranslate"><span class="pre">put</span></code>/<code class="docutils literal notranslate"><span class="pre">filter</span></code> DSL has four kinds of hashmaps. <strong>Stream records</strong> are (single-level) maps from name to value. <strong>Out-of-stream variables</strong> and <strong>local variables</strong> can also be maps, although they can be multi-level hashmaps (e.g. <code class="docutils literal notranslate"><span class="pre">&#64;sum[$x][$y]</span></code>). The fourth kind is <strong>map literals</strong>. These cannot be on the left-hand side of assignment expressions. Syntactically they look like JSON, although Miller allows string and integer keys in its map literals while JSON allows only string keys (e.g. <code class="docutils literal notranslate"><span class="pre">&quot;3&quot;</span></code> rather than <code class="docutils literal notranslate"><span class="pre">3</span></code>).</p>
<p>For example, the following swaps the input streams <code class="docutils literal notranslate"><span class="pre">a</span></code> and <code class="docutils literal notranslate"><span class="pre">i</span></code> fields, modifies <code class="docutils literal notranslate"><span class="pre">y</span></code>, and drops the rest:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --opprint put &#39;
$* = {
&quot;a&quot;: $i,
&quot;i&quot;: $a,
&quot;y&quot;: $y * 10,
}
&#39; data/small
a i y
1 pan 7.268029
2 eks 5.221511
3 wye 3.383185
4 eks 1.341887
5 wye 8.636245
</pre></div>
</div>
<p>Likewise, you can assign map literals to out-of-stream variables or local variables; pass them as arguments to user-defined functions, return them from functions, and so on:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small put &#39;
func f(map m): map {
m[&quot;x&quot;] *= 200;
return m;
}
$* = f({&quot;a&quot;: $a, &quot;x&quot;: $x});
&#39;
a=pan,x=69.358029
a=eks,x=151.735993
a=wye,x=40.920661
a=eks,x=76.279879
a=wye,x=114.657784
</pre></div>
</div>
<p>Like out-of-stream and local variables, map literals can be multi-level:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small put -q &#39;
begin {
@o = {
&quot;nrec&quot;: 0,
&quot;nkey&quot;: {&quot;numeric&quot;:0, &quot;non-numeric&quot;:0},
};
}
@o[&quot;nrec&quot;] += 1;
for (k, v in $*) {
if (is_numeric(v)) {
@o[&quot;nkey&quot;][&quot;numeric&quot;] += 1;
} else {
@o[&quot;nkey&quot;][&quot;non-numeric&quot;] += 1;
}
}
end {
dump @o;
}
&#39;
{
&quot;nrec&quot;: 5,
&quot;nkey&quot;: {
&quot;numeric&quot;: 15,
&quot;non-numeric&quot;: 10
}
}
</pre></div>
</div>
<p>By default, map-valued expressions are dumped using JSON formatting. If you use <code class="docutils literal notranslate"><span class="pre">dump</span></code> to print a hashmap with integer keys and you dont want them double-quoted (JSON-style) then you can use <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span> <span class="pre">--jknquoteint</span></code>. See also <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span> <span class="pre">--help</span></code>.</p>
</div>
<div class="section" id="type-checking">
<span id="reference-dsl-type-checking"></span><h3>Type-checking<a class="headerlink" href="#type-checking" title="Permalink to this headline"></a></h3>
<p>Millers <code class="docutils literal notranslate"><span class="pre">put</span></code>/<code class="docutils literal notranslate"><span class="pre">filter</span></code> DSLs support two optional kinds of type-checking. One is inline <strong>type-tests</strong> and <strong>type-assertions</strong> within expressions. The other is <strong>type declarations</strong> for assignments to local variables, binding of arguments to user-defined functions, and return values from user-defined functions, These are discussed in the following subsections.</p>
<p>Use of type-checking is entirely up to you: omit it if you want flexibility with heterogeneous data; use it if you want to help catch misspellings in your DSL code or unexpected irregularities in your input data.</p>
<div class="section" id="type-test-and-type-assertion-expressions">
<span id="reference-dsl-type-tests-and-assertions"></span><h4>Type-test and type-assertion expressions<a class="headerlink" href="#type-test-and-type-assertion-expressions" title="Permalink to this headline"></a></h4>
<p>The following <code class="docutils literal notranslate"><span class="pre">is...</span></code> functions take a value and return a boolean indicating whether the argument is of the indicated type. The <code class="docutils literal notranslate"><span class="pre">assert_...</span></code> functions return their argument if it is of the specified type, and cause a fatal error otherwise:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr -F | grep ^is
is_absent
is_bool
is_boolean
is_empty
is_empty_map
is_float
is_int
is_map
is_nonempty_map
is_not_empty
is_not_map
is_not_null
is_null
is_numeric
is_present
is_string
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr -F | grep ^assert
asserting_absent
asserting_bool
asserting_boolean
asserting_empty
asserting_empty_map
asserting_float
asserting_int
asserting_map
asserting_nonempty_map
asserting_not_empty
asserting_not_map
asserting_not_null
asserting_null
asserting_numeric
asserting_present
asserting_string
</pre></div>
</div>
<p>Please see <a class="reference internal" href="cookbook.html#cookbook-data-cleaning-examples"><span class="std std-ref">Data-cleaning examples</span></a> for examples of how to use these.</p>
</div>
<div class="section" id="type-declarations-for-local-variables-function-parameter-and-function-return-values">
<h4>Type-declarations for local variables, function parameter, and function return values<a class="headerlink" href="#type-declarations-for-local-variables-function-parameter-and-function-return-values" title="Permalink to this headline"></a></h4>
<p>Local variables can be defined either untyped as in <code class="docutils literal notranslate"><span class="pre">x</span> <span class="pre">=</span> <span class="pre">1</span></code>, or typed as in <code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">x</span> <span class="pre">=</span> <span class="pre">1</span></code>. Types include <strong>var</strong> (explicitly untyped), <strong>int</strong>, <strong>float</strong>, <strong>num</strong> (int or float), <strong>str</strong>, <strong>bool</strong>, and <strong>map</strong>. These optional type declarations are enforced at the time values are assigned to variables: whether at the initial value assignment as in <code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">x</span> <span class="pre">=</span> <span class="pre">1</span></code> or in any subsequent assignments to the same variable farther down in the scope.</p>
<p>The reason for <code class="docutils literal notranslate"><span class="pre">num</span></code> is that <code class="docutils literal notranslate"><span class="pre">int</span></code> and <code class="docutils literal notranslate"><span class="pre">float</span></code> typedecls are very precise:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">float</span> <span class="n">a</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="c1"># Runtime error since 0 is int not float</span>
<span class="nb">int</span> <span class="n">b</span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">;</span> <span class="c1"># Runtime error since 1.0 is float not int</span>
<span class="n">num</span> <span class="n">c</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="c1"># OK</span>
<span class="n">num</span> <span class="n">d</span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">;</span> <span class="c1"># OK</span>
</pre></div>
</div>
<p>A suggestion is to use <code class="docutils literal notranslate"><span class="pre">num</span></code> for general use when you want numeric content, and use <code class="docutils literal notranslate"><span class="pre">int</span></code> when you genuinely want integer-only values, e.g. in loop indices or map keys (since Miller map keys can only be strings or ints).</p>
<p>The <code class="docutils literal notranslate"><span class="pre">var</span></code> type declaration indicates no type restrictions, e.g. <code class="docutils literal notranslate"><span class="pre">var</span> <span class="pre">x</span> <span class="pre">=</span> <span class="pre">1</span></code> has the same type restrictions on <code class="docutils literal notranslate"><span class="pre">x</span></code> as <code class="docutils literal notranslate"><span class="pre">x</span> <span class="pre">=</span> <span class="pre">1</span></code>. The difference is in intentional shadowing: if you have <code class="docutils literal notranslate"><span class="pre">x</span> <span class="pre">=</span> <span class="pre">1</span></code> in outer scope and <code class="docutils literal notranslate"><span class="pre">x</span> <span class="pre">=</span> <span class="pre">2</span></code> in inner scope (e.g. within a for-loop or an if-statement) then outer-scope <code class="docutils literal notranslate"><span class="pre">x</span></code> has value 2 after the second assignment. But if you have <code class="docutils literal notranslate"><span class="pre">var</span> <span class="pre">x</span> <span class="pre">=</span> <span class="pre">2</span></code> in the inner scope, then you are declaring a variable scoped to the inner block.) For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="n">NR</span> <span class="o">==</span> <span class="mi">4</span><span class="p">)</span> <span class="p">{</span>
<span class="n">x</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span> <span class="c1"># Refers to outer-scope x: value changes from 1 to 2.</span>
<span class="p">}</span>
<span class="nb">print</span> <span class="n">x</span><span class="p">;</span> <span class="c1"># Value of x is now two</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="n">NR</span> <span class="o">==</span> <span class="mi">4</span><span class="p">)</span> <span class="p">{</span>
<span class="n">var</span> <span class="n">x</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span> <span class="c1"># Defines a new inner-scope x with value 2</span>
<span class="p">}</span>
<span class="nb">print</span> <span class="n">x</span><span class="p">;</span> <span class="c1"># Value of this x is still 1</span>
</pre></div>
</div>
<p>Likewise function arguments can optionally be typed, with type enforced when the function is called:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>func f(map m, int i) {
...
}
$a = f({1:2, 3:4}, 5); # OK
$b = f({1:2, 3:4}, &quot;abc&quot;); # Runtime error
$c = f({1:2, 3:4}, $x); # Runtime error for records with non-integer field named x
if (NR == 4) {
var x = 2; # Defines a new inner-scope x with value 2
}
print x; # Value of this x is still 1
</pre></div>
</div>
<p>Thirdly, function return values can be type-checked at the point of <code class="docutils literal notranslate"><span class="pre">return</span></code> using <code class="docutils literal notranslate"><span class="pre">:</span></code> and a typedecl after the parameter list:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">func</span> <span class="n">f</span><span class="p">(</span><span class="nb">map</span> <span class="n">m</span><span class="p">,</span> <span class="nb">int</span> <span class="n">i</span><span class="p">):</span> <span class="nb">bool</span> <span class="p">{</span>
<span class="o">...</span>
<span class="o">...</span>
<span class="k">if</span> <span class="p">(</span><span class="o">...</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="s2">&quot;false&quot;</span><span class="p">;</span> <span class="c1"># Runtime error if this branch is taken</span>
<span class="p">}</span>
<span class="o">...</span>
<span class="o">...</span>
<span class="k">if</span> <span class="p">(</span><span class="o">...</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="n">retval</span><span class="p">;</span> <span class="c1"># Runtime error if this function doesn&#39;t have an in-scope</span>
<span class="c1"># boolean-valued variable named retval</span>
<span class="p">}</span>
<span class="o">...</span>
<span class="o">...</span>
<span class="c1"># In Miller if your functions don&#39;t explicitly return a value, they return absent-null.</span>
<span class="c1"># So it would also be a runtime error on reaching the end of this function without</span>
<span class="c1"># an explicit return statement.</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="null-data-empty-and-absent">
<h3>Null data: empty and absent<a class="headerlink" href="#null-data-empty-and-absent" title="Permalink to this headline"></a></h3>
<p>Please see <a class="reference internal" href="reference.html#reference-null-data"><span class="std std-ref">Null data: empty and absent</span></a>.</p>
</div>
<div class="section" id="aggregate-variable-assignments">
<h3>Aggregate variable assignments<a class="headerlink" href="#aggregate-variable-assignments" title="Permalink to this headline"></a></h3>
<p>There are three remaining kinds of variable assignment using out-of-stream variables, the last two of which use the <code class="docutils literal notranslate"><span class="pre">$*</span></code> syntax:</p>
<ul class="simple">
<li><p>Recursive copy of out-of-stream variables</p></li>
<li><p>Out-of-stream variable assigned to full stream record</p></li>
<li><p>Full stream record assigned to an out-of-stream variable</p></li>
</ul>
<p>Example recursive copy of out-of-stream variables:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --opprint put -q &#39;@v[&quot;sum&quot;] += $x; @v[&quot;count&quot;] += 1; end{dump; @w = @v; dump}&#39; data/small
{
&quot;v&quot;: {
&quot;sum&quot;: 2.264762,
&quot;count&quot;: 5
}
}
{
&quot;v&quot;: {
&quot;sum&quot;: 2.264762,
&quot;count&quot;: 5
},
&quot;w&quot;: {
&quot;sum&quot;: 2.264762,
&quot;count&quot;: 5
}
}
</pre></div>
</div>
<p>Example of out-of-stream variable assigned to full stream record, where the 2nd record is stashed, and the 4th record is overwritten with that:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;NR == 2 {@keep = $*}; NR == 4 {$* = @keep}&#39; data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<p>Example of full stream record assigned to an out-of-stream variable, finding the record for which the <code class="docutils literal notranslate"><span class="pre">x</span></code> field has the largest value in the input stream:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --opprint put -q &#39;is_null(@xmax) || $x &gt; @xmax {@xmax=$x; @recmax=$*}; end {emit @recmax}&#39; data/small
a b i x y
eks pan 2 0.7586799647899636 0.5221511083334797
</pre></div>
</div>
</div>
<div class="section" id="keywords-for-filter-and-put">
<h3>Keywords for filter and put<a class="headerlink" href="#keywords-for-filter-and-put" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --help-all-keywords
all: used in &quot;emit&quot;, &quot;emitp&quot;, and &quot;unset&quot; as a synonym for @*
begin: defines a block of statements to be executed before input records
are ingested. The body statements must be wrapped in curly braces.
Example: &#39;begin { @count = 0 }&#39;
bool: declares a boolean local variable in the current curly-braced scope.
Type-checking happens at assignment: &#39;bool b = 1&#39; is an error.
break: causes execution to continue after the body of the current
for/while/do-while loop.
call: used for invoking a user-defined subroutine.
Example: &#39;subr s(k,v) { print k . &quot; is &quot; . v} call s(&quot;a&quot;, $a)&#39;
continue: causes execution to skip the remaining statements in the body of
the current for/while/do-while loop. For-loop increments are still applied.
do: with &quot;while&quot;, introduces a do-while loop. The body statements must be wrapped
in curly braces.
dump: prints all currently defined out-of-stream variables immediately
to stdout as JSON.
With &gt;, &gt;&gt;, or |, the data do not become part of the output record stream but
are instead redirected.
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
Example: mlr --from f.dat put -q &#39;@v[NR]=$*; end { dump }&#39;
Example: mlr --from f.dat put -q &#39;@v[NR]=$*; end { dump &gt; &quot;mytap.dat&quot;}&#39;
Example: mlr --from f.dat put -q &#39;@v[NR]=$*; end { dump &gt;&gt; &quot;mytap.dat&quot;}&#39;
Example: mlr --from f.dat put -q &#39;@v[NR]=$*; end { dump | &quot;jq .[]&quot;}&#39;
edump: prints all currently defined out-of-stream variables immediately
to stderr as JSON.
Example: mlr --from f.dat put -q &#39;@v[NR]=$*; end { edump }&#39;
elif: the way Miller spells &quot;else if&quot;. The body statements must be wrapped
in curly braces.
else: terminates an if/elif/elif chain. The body statements must be wrapped
in curly braces.
emit: inserts an out-of-stream variable into the output record stream. Hashmap
indices present in the data but not slotted by emit arguments are not output.
With &gt;, &gt;&gt;, or |, the data do not become part of the output record stream but
are instead redirected.
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
You can use any of the output-format command-line flags, e.g. --ocsv, --ofs,
etc., to control the format of the output if the output is redirected. See also mlr -h.
Example: mlr --from f.dat put &#39;emit &gt; &quot;/tmp/data-&quot;.$a, $*&#39;
Example: mlr --from f.dat put &#39;emit &gt; &quot;/tmp/data-&quot;.$a, mapexcept($*, &quot;a&quot;)&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit @sums&#39;
Example: mlr --from f.dat put --ojson &#39;@sums[$a][$b]+=$x; emit &gt; &quot;tap-&quot;.$a.$b.&quot;.dat&quot;, @sums&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit @sums, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit &gt; &quot;mytap.dat&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit &gt;&gt; &quot;mytap.dat&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit | &quot;gzip &gt; mytap.dat.gz&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit &gt; stderr, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit | &quot;grep somepattern&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Please see http://johnkerl.org/miller/doc for more information.
emitf: inserts non-indexed out-of-stream variable(s) side-by-side into the
output record stream.
With &gt;, &gt;&gt;, or |, the data do not become part of the output record stream but
are instead redirected.
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
You can use any of the output-format command-line flags, e.g. --ocsv, --ofs,
etc., to control the format of the output if the output is redirected. See also mlr -h.
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf @a&#39;
Example: mlr --from f.dat put --oxtab &#39;@a=$i;@b+=$x;@c+=$y; emitf &gt; &quot;tap-&quot;.$i.&quot;.dat&quot;, @a&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf &gt; &quot;mytap.dat&quot;, @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf &gt;&gt; &quot;mytap.dat&quot;, @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf &gt; stderr, @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf | &quot;grep somepattern&quot;, @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf | &quot;grep somepattern &gt; mytap.dat&quot;, @a, @b, @c&#39;
Please see http://johnkerl.org/miller/doc for more information.
emitp: inserts an out-of-stream variable into the output record stream.
Hashmap indices present in the data but not slotted by emitp arguments are
output concatenated with &quot;:&quot;.
With &gt;, &gt;&gt;, or |, the data do not become part of the output record stream but
are instead redirected.
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
You can use any of the output-format command-line flags, e.g. --ocsv, --ofs,
etc., to control the format of the output if the output is redirected. See also mlr -h.
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp @sums&#39;
Example: mlr --from f.dat put --opprint &#39;@sums[$a][$b]+=$x; emitp &gt; &quot;tap-&quot;.$a.$b.&quot;.dat&quot;, @sums&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp @sums, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp &gt; &quot;mytap.dat&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp &gt;&gt; &quot;mytap.dat&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp | &quot;gzip &gt; mytap.dat.gz&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp &gt; stderr, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp | &quot;grep somepattern&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Please see http://johnkerl.org/miller/doc for more information.
end: defines a block of statements to be executed after input records
are ingested. The body statements must be wrapped in curly braces.
Example: &#39;end { emit @count }&#39;
Example: &#39;end { eprint &quot;Final count is &quot; . @count }&#39;
eprint: prints expression immediately to stderr.
Example: mlr --from f.dat put -q &#39;eprint &quot;The sum of x and y is &quot;.($x+$y)&#39;
Example: mlr --from f.dat put -q &#39;for (k, v in $*) { eprint k . &quot; =&gt; &quot; . v }&#39;
Example: mlr --from f.dat put &#39;(NR % 1000 == 0) { eprint &quot;Checkpoint &quot;.NR}&#39;
eprintn: prints expression immediately to stderr, without trailing newline.
Example: mlr --from f.dat put -q &#39;eprintn &quot;The sum of x and y is &quot;.($x+$y); eprint &quot;&quot;&#39;
false: the boolean literal value.
filter: includes/excludes the record in the output record stream.
Example: mlr --from f.dat put &#39;filter (NR == 2 || $x &gt; 5.4)&#39;
Instead of put with &#39;filter false&#39; you can simply use put -q. The following
uses the input record to accumulate data but only prints the running sum
without printing the input record:
Example: mlr --from f.dat put -q &#39;@running_sum += $x * $y; emit @running_sum&#39;
float: declares a floating-point local variable in the current curly-braced scope.
Type-checking happens at assignment: &#39;float x = 0&#39; is an error.
for: defines a for-loop using one of three styles. The body statements must
be wrapped in curly braces.
For-loop over stream record:
Example: &#39;for (k, v in $*) { ... }&#39;
For-loop over out-of-stream variables:
Example: &#39;for (k, v in @counts) { ... }&#39;
Example: &#39;for ((k1, k2), v in @counts) { ... }&#39;
Example: &#39;for ((k1, k2, k3), v in @*) { ... }&#39;
C-style for-loop:
Example: &#39;for (var i = 0, var b = 1; i &lt; 10; i += 1, b *= 2) { ... }&#39;
func: used for defining a user-defined function.
Example: &#39;func f(a,b) { return sqrt(a**2+b**2)} $d = f($x, $y)&#39;
if: starts an if/elif/elif chain. The body statements must be wrapped
in curly braces.
in: used in for-loops over stream records or out-of-stream variables.
int: declares an integer local variable in the current curly-braced scope.
Type-checking happens at assignment: &#39;int x = 0.0&#39; is an error.
map: declares an map-valued local variable in the current curly-braced scope.
Type-checking happens at assignment: &#39;map b = 0&#39; is an error. map b = {} is
always OK. map b = a is OK or not depending on whether a is a map.
num: declares an int/float local variable in the current curly-braced scope.
Type-checking happens at assignment: &#39;num b = true&#39; is an error.
print: prints expression immediately to stdout.
Example: mlr --from f.dat put -q &#39;print &quot;The sum of x and y is &quot;.($x+$y)&#39;
Example: mlr --from f.dat put -q &#39;for (k, v in $*) { print k . &quot; =&gt; &quot; . v }&#39;
Example: mlr --from f.dat put &#39;(NR % 1000 == 0) { print &gt; stderr, &quot;Checkpoint &quot;.NR}&#39;
printn: prints expression immediately to stdout, without trailing newline.
Example: mlr --from f.dat put -q &#39;printn &quot;.&quot;; end { print &quot;&quot; }&#39;
return: specifies the return value from a user-defined function.
Omitted return statements (including via if-branches) result in an absent-null
return value, which in turns results in a skipped assignment to an LHS.
stderr: Used for tee, emit, emitf, emitp, print, and dump in place of filename
to print to standard error.
stdout: Used for tee, emit, emitf, emitp, print, and dump in place of filename
to print to standard output.
str: declares a string local variable in the current curly-braced scope.
Type-checking happens at assignment.
subr: used for defining a subroutine.
Example: &#39;subr s(k,v) { print k . &quot; is &quot; . v} call s(&quot;a&quot;, $a)&#39;
tee: prints the current record to specified file.
This is an immediate print to the specified file (except for pprint format
which of course waits until the end of the input stream to format all output).
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
You can use any of the output-format command-line flags, e.g. --ocsv, --ofs,
etc., to control the format of the output. See also mlr -h.
emit with redirect and tee with redirect are identical, except tee can only
output $*.
Example: mlr --from f.dat put &#39;tee &gt; &quot;/tmp/data-&quot;.$a, $*&#39;
Example: mlr --from f.dat put &#39;tee &gt;&gt; &quot;/tmp/data-&quot;.$a.$b, $*&#39;
Example: mlr --from f.dat put &#39;tee &gt; stderr, $*&#39;
Example: mlr --from f.dat put -q &#39;tee | &quot;tr [a-z\] [A-Z\]&quot;, $*&#39;
Example: mlr --from f.dat put -q &#39;tee | &quot;tr [a-z\] [A-Z\] &gt; /tmp/data-&quot;.$a, $*&#39;
Example: mlr --from f.dat put -q &#39;tee | &quot;gzip &gt; /tmp/data-&quot;.$a.&quot;.gz&quot;, $*&#39;
Example: mlr --from f.dat put -q --ojson &#39;tee | &quot;gzip &gt; /tmp/data-&quot;.$a.&quot;.gz&quot;, $*&#39;
true: the boolean literal value.
unset: clears field(s) from the current record, or an out-of-stream or local variable.
Example: mlr --from f.dat put &#39;unset $x&#39;
Example: mlr --from f.dat put &#39;unset $*&#39;
Example: mlr --from f.dat put &#39;for (k, v in $*) { if (k =~ &quot;a.*&quot;) { unset $[k] } }&#39;
Example: mlr --from f.dat put &#39;...; unset @sums&#39;
Example: mlr --from f.dat put &#39;...; unset @sums[&quot;green&quot;]&#39;
Example: mlr --from f.dat put &#39;...; unset @*&#39;
var: declares an untyped local variable in the current curly-braced scope.
Examples: &#39;var a=1&#39;, &#39;var xyz=&quot;&quot;&#39;
while: introduces a while loop, or with &quot;do&quot;, introduces a do-while loop.
The body statements must be wrapped in curly braces.
ENV: access to environment variables by name, e.g. &#39;$home = ENV[&quot;HOME&quot;]&#39;
FILENAME: evaluates to the name of the current file being processed.
FILENUM: evaluates to the number of the current file being processed,
starting with 1.
FNR: evaluates to the number of the current record within the current file
being processed, starting with 1. Resets at the start of each file.
IFS: evaluates to the input field separator from the command line.
IPS: evaluates to the input pair separator from the command line.
IRS: evaluates to the input record separator from the command line,
or to LF or CRLF from the input data if in autodetect mode (which is
the default).
M_E: the mathematical constant e.
M_PI: the mathematical constant pi.
NF: evaluates to the number of fields in the current record.
NR: evaluates to the number of the current record over all files
being processed, starting with 1. Does not reset at the start of each file.
OFS: evaluates to the output field separator from the command line.
OPS: evaluates to the output pair separator from the command line.
ORS: evaluates to the output record separator from the command line,
or to LF or CRLF from the input data if in autodetect mode (which is
the default).
</pre></div>
</div>
</div>
</div>
<div class="section" id="operator-precedence">
<h2>Operator precedence<a class="headerlink" href="#operator-precedence" title="Permalink to this headline"></a></h2>
<p>Operators are listed in order of decreasing precedence, highest first.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>Operators Associativity
--------- -------------
() left to right
** right to left
! ~ unary+ unary- &amp; right to left
binary* / // % left to right
binary+ binary- . left to right
&lt;&lt; &gt;&gt; left to right
&amp; left to right
^ left to right
| left to right
&lt; &lt;= &gt; &gt;= left to right
== != =~ !=~ left to right
&amp;&amp; left to right
^^ left to right
|| left to right
? : right to left
= N/A for Miller (there is no $a=$b=$c)
</pre></div>
</div>
</div>
<div class="section" id="operator-and-function-semantics">
<h2>Operator and function semantics<a class="headerlink" href="#operator-and-function-semantics" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Functions are in general pass-throughs straight to the system-standard C library.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">min</span></code> and <code class="docutils literal notranslate"><span class="pre">max</span></code> functions are different from other multi-argument functions which return null if any of their inputs are null: for <code class="docutils literal notranslate"><span class="pre">min</span></code> and <code class="docutils literal notranslate"><span class="pre">max</span></code>, by contrast, if one argument is absent-null, the other is returned. Empty-null loses min or max against numeric or boolean; empty-null is less than any other string.</p></li>
<li><p>Symmetrically with respect to the bitwise OR, XOR, and AND operators <code class="docutils literal notranslate"><span class="pre">|</span></code>, <code class="docutils literal notranslate"><span class="pre">^</span></code>, <code class="docutils literal notranslate"><span class="pre">&amp;</span></code>, Miller has logical operators <code class="docutils literal notranslate"><span class="pre">||</span></code>, <code class="docutils literal notranslate"><span class="pre">^^</span></code>, <code class="docutils literal notranslate"><span class="pre">&amp;&amp;</span></code>: the logical XOR not existing in C.</p></li>
<li><p>The exponentiation operator <code class="docutils literal notranslate"><span class="pre">**</span></code> is familiar from many languages.</p></li>
<li><p>The regex-match and regex-not-match operators <code class="docutils literal notranslate"><span class="pre">=~</span></code> and <code class="docutils literal notranslate"><span class="pre">!=~</span></code> are similar to those in Ruby and Perl.</p></li>
</ul>
</div>
<div class="section" id="control-structures">
<h2>Control structures<a class="headerlink" href="#control-structures" title="Permalink to this headline"></a></h2>
<div class="section" id="pattern-action-blocks">
<h3>Pattern-action blocks<a class="headerlink" href="#pattern-action-blocks" title="Permalink to this headline"></a></h3>
<p>These are reminiscent of <code class="docutils literal notranslate"><span class="pre">awk</span></code> syntax. They can be used to allow assignments to be done only when appropriate e.g. for math-function domain restrictions, regex-matching, and so on:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr cat data/put-gating-example-1.dkvp
x=-1
x=0
x=1
x=2
x=3
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$x &gt; 0.0 { $y = log10($x); $z = sqrt($y) }&#39; data/put-gating-example-1.dkvp
x=-1
x=0
x=1,y=0.000000,z=0.000000
x=2,y=0.301030,z=0.548662
x=3,y=0.477121,z=0.690740
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr cat data/put-gating-example-2.dkvp
a=abc_123
a=some other name
a=xyz_789
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$a =~ &quot;([a-z]+)_([0-9]+)&quot; { $b = &quot;left_\1&quot;; $c = &quot;right_\2&quot; }&#39; data/put-gating-example-2.dkvp
a=abc_123,b=left_abc,c=right_123
a=some other name
a=xyz_789,b=left_xyz,c=right_789
</pre></div>
</div>
<p>This produces heteregenous output which Miller, of course, has no problems with (see <a class="reference internal" href="record-heterogeneity.html"><span class="doc">Record-heterogeneity</span></a>). But if you want homogeneous output, the curly braces can be replaced with a semicolon between the expression and the body statements. This causes <code class="docutils literal notranslate"><span class="pre">put</span></code> to evaluate the boolean expression (along with any side effects, namely, regex-captures <code class="docutils literal notranslate"><span class="pre">\1</span></code>, <code class="docutils literal notranslate"><span class="pre">\2</span></code>, etc.) but doesnt use it as a criterion for whether subsequent assignments should be executed. Instead, subsequent assignments are done unconditionally:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$x &gt; 0.0; $y = log10($x); $z = sqrt($y)&#39; data/put-gating-example-1.dkvp
x=-1,y=nan,z=nan
x=0,y=-inf,z=nan
x=1,y=0.000000,z=0.000000
x=2,y=0.301030,z=0.548662
x=3,y=0.477121,z=0.690740
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$a =~ &quot;([a-z]+)_([0-9]+)&quot;; $b = &quot;left_\1&quot;; $c = &quot;right_\2&quot;&#39; data/put-gating-example-2.dkvp
a=abc_123,b=left_abc,c=right_123
a=some other name,b=left_,c=right_
a=xyz_789,b=left_xyz,c=right_789
</pre></div>
</div>
</div>
<div class="section" id="if-statements">
<h3>If-statements<a class="headerlink" href="#if-statements" title="Permalink to this headline"></a></h3>
<p>These are again reminiscent of <code class="docutils literal notranslate"><span class="pre">awk</span></code>. Pattern-action blocks are a special case of <code class="docutils literal notranslate"><span class="pre">if</span></code> with no <code class="docutils literal notranslate"><span class="pre">elif</span></code> or <code class="docutils literal notranslate"><span class="pre">else</span></code> blocks, no <code class="docutils literal notranslate"><span class="pre">if</span></code> keyword, and parentheses optional around the boolean expression:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;NR == 4 {$foo = &quot;bar&quot;}&#39;</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;if (NR == 4) {$foo = &quot;bar&quot;}&#39;</span>
</pre></div>
</div>
<p>Compound statements use <code class="docutils literal notranslate"><span class="pre">elif</span></code> (rather than <code class="docutils literal notranslate"><span class="pre">elsif</span></code> or <code class="docutils literal notranslate"><span class="pre">else</span> <span class="pre">if</span></code>):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mlr</span> <span class="n">put</span> <span class="s1">&#39;</span>
<span class="k">if</span> <span class="p">(</span><span class="n">NR</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
<span class="o">...</span>
<span class="p">}</span> <span class="k">elif</span> <span class="p">(</span><span class="n">NR</span> <span class="o">==</span><span class="mi">4</span><span class="p">)</span> <span class="p">{</span>
<span class="o">...</span>
<span class="p">}</span> <span class="k">elif</span> <span class="p">(</span><span class="n">NR</span> <span class="o">==</span><span class="mi">6</span><span class="p">)</span> <span class="p">{</span>
<span class="o">...</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="o">...</span>
<span class="p">}</span>
<span class="s1">&#39;</span>
</pre></div>
</div>
</div>
<div class="section" id="while-and-do-while-loops">
<h3>While and do-while loops<a class="headerlink" href="#while-and-do-while-loops" title="Permalink to this headline"></a></h3>
<p>Millers <code class="docutils literal notranslate"><span class="pre">while</span></code> and <code class="docutils literal notranslate"><span class="pre">do-while</span></code> are unsurprising in comparison to various languages, as are <code class="docutils literal notranslate"><span class="pre">break</span></code> and <code class="docutils literal notranslate"><span class="pre">continue</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ echo x=1,y=2 | mlr put &#39;
while (NF &lt; 10) {
$[NF+1] = &quot;&quot;
}
$foo = &quot;bar&quot;
&#39;
x=1,y=2,3=,4=,5=,6=,7=,8=,9=,10=,foo=bar
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ echo x=1,y=2 | mlr put &#39;
do {
$[NF+1] = &quot;&quot;;
if (NF == 5) {
break
}
} while (NF &lt; 10);
$foo = &quot;bar&quot;
&#39;
x=1,y=2,3=,4=,5=,foo=bar
</pre></div>
</div>
<p>A <code class="docutils literal notranslate"><span class="pre">break</span></code> or <code class="docutils literal notranslate"><span class="pre">continue</span></code> within nested conditional blocks or if-statements will, of course, propagate to the innermost loop enclosing them, if any. A <code class="docutils literal notranslate"><span class="pre">break</span></code> or <code class="docutils literal notranslate"><span class="pre">continue</span></code> outside a loop is a syntax error that will be flagged as soon as the expression is parsed, before any input records are ingested.
The existence of <code class="docutils literal notranslate"><span class="pre">while</span></code>, <code class="docutils literal notranslate"><span class="pre">do-while</span></code>, and <code class="docutils literal notranslate"><span class="pre">for</span></code> loops in Millers DSL means that you can create infinite-loop scenarios inadvertently. In particular, please recall that DSL statements are executed once if in <code class="docutils literal notranslate"><span class="pre">begin</span></code> or <code class="docutils literal notranslate"><span class="pre">end</span></code> blocks, and once <em>per record</em> otherwise. For example, <strong>while (NR &lt; 10) will never terminate as NR is only incremented between records</strong>.</p>
</div>
<div class="section" id="for-loops">
<h3>For-loops<a class="headerlink" href="#for-loops" title="Permalink to this headline"></a></h3>
<p>While Millers <code class="docutils literal notranslate"><span class="pre">while</span></code> and <code class="docutils literal notranslate"><span class="pre">do-while</span></code> statements are much as in many other languages, <code class="docutils literal notranslate"><span class="pre">for</span></code> loops are more idiosyncratic to Miller. They are loops over key-value pairs, whether in stream records, out-of-stream variables, local variables, or map-literals: more reminiscent of <code class="docutils literal notranslate"><span class="pre">foreach</span></code>, as in (for example) PHP. There are <strong>for-loops over map keys</strong> and <strong>for-loops over key-value tuples</strong>. Additionally, Miller has a <strong>C-style triple-for loop</strong> with initialize, test, and update statements.</p>
<p>As with <code class="docutils literal notranslate"><span class="pre">while</span></code> and <code class="docutils literal notranslate"><span class="pre">do-while</span></code>, a <code class="docutils literal notranslate"><span class="pre">break</span></code> or <code class="docutils literal notranslate"><span class="pre">continue</span></code> within nested control structures will propagate to the innermost loop enclosing them, if any, and a <code class="docutils literal notranslate"><span class="pre">break</span></code> or <code class="docutils literal notranslate"><span class="pre">continue</span></code> outside a loop is a syntax error that will be flagged as soon as the expression is parsed, before any input records are ingested.</p>
<div class="section" id="key-only-for-loops">
<h4>Key-only for-loops<a class="headerlink" href="#key-only-for-loops" title="Permalink to this headline"></a></h4>
<p>The <code class="docutils literal notranslate"><span class="pre">key</span></code> variable is always bound to the <em>key</em> of key-value pairs:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small put &#39;
print &quot;NR = &quot;.NR;
for (key in $*) {
value = $[key];
print &quot; key:&quot; . key . &quot; value:&quot;.value;
}
&#39;
NR = 1
key:a value:pan
key:b value:pan
key:i value:1
key:x value:0.346790
key:y value:0.726803
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
NR = 2
key:a value:eks
key:b value:pan
key:i value:2
key:x value:0.758680
key:y value:0.522151
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
NR = 3
key:a value:wye
key:b value:wye
key:i value:3
key:x value:0.204603
key:y value:0.338319
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
NR = 4
key:a value:eks
key:b value:wye
key:i value:4
key:x value:0.381399
key:y value:0.134189
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
NR = 5
key:a value:wye
key:b value:pan
key:i value:5
key:x value:0.573289
key:y value:0.863624
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr -n put &#39;
end {
o = {1:2, 3:{4:5}};
for (key in o) {
print &quot; key:&quot; . key . &quot; valuetype:&quot; . typeof(o[key]);
}
}
&#39;
key:1 valuetype:int
key:3 valuetype:map
</pre></div>
</div>
<p>Note that the value corresponding to a given key may be gotten as through a <strong>computed field name</strong> using square brackets as in <code class="docutils literal notranslate"><span class="pre">$[key]</span></code> for stream records, or by indexing the looped-over variable using square brackets.</p>
</div>
<div class="section" id="key-value-for-loops">
<h4>Key-value for-loops<a class="headerlink" href="#key-value-for-loops" title="Permalink to this headline"></a></h4>
<p>Single-level keys may be gotten at using either <code class="docutils literal notranslate"><span class="pre">for(k,v)</span></code> or <code class="docutils literal notranslate"><span class="pre">for((k),v)</span></code>; multi-level keys may be gotten at using <code class="docutils literal notranslate"><span class="pre">for((k1,k2,k3),v)</span></code> and so on. The <code class="docutils literal notranslate"><span class="pre">v</span></code> variable will be bound to to a scalar value (a string or a number) if the map stops at that level, or to a map-valued variable if the map goes deeper. If the map isnt deep enough then the loop body wont be executed.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/for-srec-example.tbl
label1 label2 f1 f2 f3
blue green 100 240 350
red green 120 11 195
yellow blue 140 0 240
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --pprint --from data/for-srec-example.tbl put &#39;
$sum1 = $f1 + $f2 + $f3;
$sum2 = 0;
$sum3 = 0;
for (key, value in $*) {
if (key =~ &quot;^f[0-9]+&quot;) {
$sum2 += value;
$sum3 += $[key];
}
}
&#39;
label1 label2 f1 f2 f3 sum1 sum2 sum3
blue green 100 240 350 690 690 690
red green 120 11 195 326 326 326
yellow blue 140 0 240 380 380 380
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small --opprint put &#39;for (k,v in $*) { $[k.&quot;_type&quot;] = typeof(v) }&#39;
a b i x y a_type b_type i_type x_type y_type
pan pan 1 0.3467901443380824 0.7268028627434533 string string int float float
eks pan 2 0.7586799647899636 0.5221511083334797 string string int float float
wye wye 3 0.20460330576630303 0.33831852551664776 string string int float float
eks wye 4 0.38139939387114097 0.13418874328430463 string string int float float
wye pan 5 0.5732889198020006 0.8636244699032729 string string int float float
</pre></div>
</div>
<p>Note that the value of the current field in the for-loop can be gotten either using the bound variable <code class="docutils literal notranslate"><span class="pre">value</span></code>, or through a <strong>computed field name</strong> using square brackets as in <code class="docutils literal notranslate"><span class="pre">$[key]</span></code>.</p>
<p>Important note: to avoid inconsistent looping behavior in case youre setting new fields (and/or unsetting existing ones) while looping over the record, <strong>Miller makes a copy of the record before the loop: loop variables are bound from the copy and all other reads/writes involve the record itself</strong>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small --opprint put &#39;
$sum1 = 0;
$sum2 = 0;
for (k,v in $*) {
if (is_numeric(v)) {
$sum1 +=v;
$sum2 += $[k];
}
}
&#39;
a b i x y sum1 sum2
pan pan 1 0.3467901443380824 0.7268028627434533 2.073593 8.294372
eks pan 2 0.7586799647899636 0.5221511083334797 3.280831 13.123324
wye wye 3 0.20460330576630303 0.33831852551664776 3.542922 14.171687
eks wye 4 0.38139939387114097 0.13418874328430463 4.515588 18.062353
wye pan 5 0.5732889198020006 0.8636244699032729 6.436913 25.747654
</pre></div>
</div>
<p>It can be confusing to modify the stream record while iterating over a copy of it, so instead you might find it simpler to use a local variable in the loop and only update the stream record after the loop:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small --opprint put &#39;
sum = 0;
for (k,v in $*) {
if (is_numeric(v)) {
sum += $[k];
}
}
$sum = sum
&#39;
a b i x y sum
pan pan 1 0.3467901443380824 0.7268028627434533 2.073593
eks pan 2 0.7586799647899636 0.5221511083334797 3.280831
wye wye 3 0.20460330576630303 0.33831852551664776 3.542922
eks wye 4 0.38139939387114097 0.13418874328430463 4.515588
wye pan 5 0.5732889198020006 0.8636244699032729 6.436913
</pre></div>
</div>
<p>You can also start iterating on sub-hashmaps of an out-of-stream or local variable; you can loop over nested keys; you can loop over all out-of-stream variables. The bound variables are bound to a copy of the sub-hashmap as it was before the loop started. The sub-hashmap is specified by square-bracketed indices after <code class="docutils literal notranslate"><span class="pre">in</span></code>, and additional deeper indices are bound to loop key-variables. The terminal values are bound to the loop value-variable whenever the keys are not too shallow. The value-variable may refer to a terminal (string, number) or it may be map-valued if the map goes deeper. Example indexing is as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># Parentheses are optional for single key:</span>
<span class="k">for</span> <span class="p">(</span><span class="n">k1</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nd">@a</span><span class="p">[</span><span class="s2">&quot;b&quot;</span><span class="p">][</span><span class="s2">&quot;c&quot;</span><span class="p">])</span> <span class="p">{</span> <span class="o">...</span> <span class="p">}</span>
<span class="k">for</span> <span class="p">((</span><span class="n">k1</span><span class="p">),</span> <span class="n">v</span> <span class="ow">in</span> <span class="nd">@a</span><span class="p">[</span><span class="s2">&quot;b&quot;</span><span class="p">][</span><span class="s2">&quot;c&quot;</span><span class="p">])</span> <span class="p">{</span> <span class="o">...</span> <span class="p">}</span>
<span class="c1"># Parentheses are required for multiple keys:</span>
<span class="k">for</span> <span class="p">((</span><span class="n">k1</span><span class="p">,</span> <span class="n">k2</span><span class="p">),</span> <span class="n">v</span> <span class="ow">in</span> <span class="nd">@a</span><span class="p">[</span><span class="s2">&quot;b&quot;</span><span class="p">][</span><span class="s2">&quot;c&quot;</span><span class="p">])</span> <span class="p">{</span> <span class="o">...</span> <span class="p">}</span> <span class="c1"># Loop over subhashmap of a variable</span>
<span class="k">for</span> <span class="p">((</span><span class="n">k1</span><span class="p">,</span> <span class="n">k2</span><span class="p">,</span> <span class="n">k3</span><span class="p">),</span> <span class="n">v</span> <span class="ow">in</span> <span class="nd">@a</span><span class="p">[</span><span class="s2">&quot;b&quot;</span><span class="p">][</span><span class="s2">&quot;c&quot;</span><span class="p">])</span> <span class="p">{</span> <span class="o">...</span> <span class="p">}</span> <span class="c1"># Ditto</span>
<span class="k">for</span> <span class="p">((</span><span class="n">k1</span><span class="p">,</span> <span class="n">k2</span><span class="p">,</span> <span class="n">k3</span><span class="p">),</span> <span class="n">v</span> <span class="ow">in</span> <span class="nd">@a</span> <span class="p">{</span> <span class="o">...</span> <span class="p">}</span> <span class="c1"># Loop over variable starting from basename</span>
<span class="k">for</span> <span class="p">((</span><span class="n">k1</span><span class="p">,</span> <span class="n">k2</span><span class="p">,</span> <span class="n">k3</span><span class="p">),</span> <span class="n">v</span> <span class="ow">in</span> <span class="o">@*</span> <span class="p">{</span> <span class="o">...</span> <span class="p">}</span> <span class="c1"># Loop over all variables (k1 is bound to basename)</span>
</pre></div>
</div>
<p>Thats confusing in the abstract, so a concrete example is in order. Suppose the out-of-stream variable <code class="docutils literal notranslate"><span class="pre">&#64;myvar</span></code> is populated as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr -n put --jknquoteint -q &#39;
begin {
@myvar = {
1: 2,
3: { 4 : 5 },
6: { 7: { 8: 9 } }
}
}
end { dump }
&#39;
{
&quot;myvar&quot;: {
1: 2,
3: {
4: 5
},
6: {
7: {
8: 9
}
}
}
}
</pre></div>
</div>
<p>Then we can get at various values as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr -n put --jknquoteint -q &#39;
begin {
@myvar = {
1: 2,
3: { 4 : 5 },
6: { 7: { 8: 9 } }
}
}
end {
for (k, v in @myvar) {
print
&quot;key=&quot; . k .
&quot;,valuetype=&quot; . typeof(v);
}
}
&#39;
key=1,valuetype=int
key=3,valuetype=map
key=6,valuetype=map
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr -n put --jknquoteint -q &#39;
begin {
@myvar = {
1: 2,
3: { 4 : 5 },
6: { 7: { 8: 9 } }
}
}
end {
for ((k1, k2), v in @myvar) {
print
&quot;key1=&quot; . k1 .
&quot;,key2=&quot; . k2 .
&quot;,valuetype=&quot; . typeof(v);
}
}
&#39;
key1=3,key2=4,valuetype=int
key1=6,key2=7,valuetype=map
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr -n put --jknquoteint -q &#39;
begin {
@myvar = {
1: 2,
3: { 4 : 5 },
6: { 7: { 8: 9 } }
}
}
end {
for ((k1, k2), v in @myvar[6]) {
print
&quot;key1=&quot; . k1 .
&quot;,key2=&quot; . k2 .
&quot;,valuetype=&quot; . typeof(v);
}
}
&#39;
key1=7,key2=8,valuetype=int
</pre></div>
</div>
</div>
<div class="section" id="c-style-triple-for-loops">
<h4>C-style triple-for loops<a class="headerlink" href="#c-style-triple-for-loops" title="Permalink to this headline"></a></h4>
<p>These are supported as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small --opprint put &#39;
num suma = 0;
for (a = 1; a &lt;= NR; a += 1) {
suma += a;
}
$suma = suma;
&#39;
a b i x y suma
pan pan 1 0.3467901443380824 0.7268028627434533 1
eks pan 2 0.7586799647899636 0.5221511083334797 3
wye wye 3 0.20460330576630303 0.33831852551664776 6
eks wye 4 0.38139939387114097 0.13418874328430463 10
wye pan 5 0.5732889198020006 0.8636244699032729 15
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small --opprint put &#39;
num suma = 0;
num sumb = 0;
for (num a = 1, num b = 1; a &lt;= NR; a += 1, b *= 2) {
suma += a;
sumb += b;
}
$suma = suma;
$sumb = sumb;
&#39;
a b i x y suma sumb
pan pan 1 0.3467901443380824 0.7268028627434533 1 1
eks pan 2 0.7586799647899636 0.5221511083334797 3 3
wye wye 3 0.20460330576630303 0.33831852551664776 6 7
eks wye 4 0.38139939387114097 0.13418874328430463 10 15
wye pan 5 0.5732889198020006 0.8636244699032729 15 31
</pre></div>
</div>
<p>Notes:</p>
<ul class="simple">
<li><p>In <code class="docutils literal notranslate"><span class="pre">for</span> <span class="pre">(start;</span> <span class="pre">continuation;</span> <span class="pre">update)</span> <span class="pre">{</span> <span class="pre">body</span> <span class="pre">}</span></code>, the start, continuation, and update statements may be empty, single statements, or multiple comma-separated statements. If the continuation is empty (e.g. <code class="docutils literal notranslate"><span class="pre">for(i=1;;i+=1)</span></code>) it defaults to true.</p></li>
<li><p>In particular, you may use <code class="docutils literal notranslate"><span class="pre">$</span></code>-variables and/or <code class="docutils literal notranslate"><span class="pre">&#64;</span></code>-variables in the start, continuation, and/or update steps (as well as the body, of course).</p></li>
<li><p>The typedecls such as <code class="docutils literal notranslate"><span class="pre">int</span></code> or <code class="docutils literal notranslate"><span class="pre">num</span></code> are optional. If a typedecl is provided (for a local variable), it binds a variable scoped to the for-loop regardless of whether a same-name variable is present in outer scope. If a typedecl is not provided, then the variable is scoped to the for-loop if no same-name variable is present in outer scope, or if a same-name variable is present in outer scope then it is modified.</p></li>
<li><p>Miller has no <code class="docutils literal notranslate"><span class="pre">++</span></code> or <code class="docutils literal notranslate"><span class="pre">--</span></code> operators.</p></li>
<li><p>As with all for/if/while statements in Miller, the curly braces are required even if the body is a single statement, or empty.</p></li>
</ul>
</div>
</div>
<div class="section" id="begin-end-blocks">
<h3>Begin/end blocks<a class="headerlink" href="#begin-end-blocks" title="Permalink to this headline"></a></h3>
<p>Miller supports an <code class="docutils literal notranslate"><span class="pre">awk</span></code>-like <code class="docutils literal notranslate"><span class="pre">begin/end</span></code> syntax. The statements in the <code class="docutils literal notranslate"><span class="pre">begin</span></code> block are executed before any input records are read; the statements in the <code class="docutils literal notranslate"><span class="pre">end</span></code> block are executed after the last input record is read. (If you want to execute some statement at the start of each file, not at the start of the first file as with <code class="docutils literal notranslate"><span class="pre">begin</span></code>, you might use a pattern/action block of the form <code class="docutils literal notranslate"><span class="pre">FNR</span> <span class="pre">==</span> <span class="pre">1</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">}</span></code>.) All statements outside of <code class="docutils literal notranslate"><span class="pre">begin</span></code> or <code class="docutils literal notranslate"><span class="pre">end</span></code> are, of course, executed on every input record. Semicolons separate statements inside or outside of begin/end blocks; semicolons are required between begin/end block bodies and any subsequent statement. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;
begin { @sum = 0 };
@x_sum += $x;
end { emit @x_sum }
&#39; ../data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
a=zee,b=pan,i=6,x=0.5271261600918548,y=0.49322128674835697
a=eks,b=zee,i=7,x=0.6117840605678454,y=0.1878849191181694
a=zee,b=wye,i=8,x=0.5985540091064224,y=0.976181385699006
a=hat,b=wye,i=9,x=0.03144187646093577,y=0.7495507603507059
a=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864
x_sum=4.536294
</pre></div>
</div>
<p>Since uninitialized out-of-stream variables default to 0 for addition/substraction and 1 for multiplication when they appear on expression right-hand sides (not quite as in <code class="docutils literal notranslate"><span class="pre">awk</span></code>, where theyd default to 0 either way), the above can be written more succinctly as</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;
@x_sum += $x;
end { emit @x_sum }
&#39; ../data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
a=zee,b=pan,i=6,x=0.5271261600918548,y=0.49322128674835697
a=eks,b=zee,i=7,x=0.6117840605678454,y=0.1878849191181694
a=zee,b=wye,i=8,x=0.5985540091064224,y=0.976181385699006
a=hat,b=wye,i=9,x=0.03144187646093577,y=0.7495507603507059
a=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864
x_sum=4.536294
</pre></div>
</div>
<p>The <strong>put -q</strong> option is a shorthand which suppresses printing of each output record, with only <code class="docutils literal notranslate"><span class="pre">emit</span></code> statements being output. So to get only summary outputs, one could write</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;
@x_sum += $x;
end { emit @x_sum }
&#39; ../data/small
x_sum=4.536294
</pre></div>
</div>
<p>We can do similarly with multiple out-of-stream variables:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;
@x_count += 1;
@x_sum += $x;
end {
emit @x_count;
emit @x_sum;
}
&#39; ../data/small
x_count=10
x_sum=4.536294
</pre></div>
</div>
<p>This is of course not much different than</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr stats1 -a count,sum -f x ../data/small
x_count=10,x_sum=4.536294
</pre></div>
</div>
<p>Note that its a syntax error for begin/end blocks to refer to field names (beginning with <code class="docutils literal notranslate"><span class="pre">$</span></code>), since these execute outside the context of input records.</p>
</div>
</div>
<div class="section" id="output-statements">
<h2>Output statements<a class="headerlink" href="#output-statements" title="Permalink to this headline"></a></h2>
<p>You can <strong>output</strong> variable-values or expressions in <strong>five ways</strong>:</p>
<ul class="simple">
<li><p><strong>Assign</strong> them to stream-record fields. For example, <code class="docutils literal notranslate"><span class="pre">$cumulative_sum</span> <span class="pre">=</span> <span class="pre">&#64;sum</span></code>. For another example, <code class="docutils literal notranslate"><span class="pre">$nr</span> <span class="pre">=</span> <span class="pre">NR</span></code> adds a field named <code class="docutils literal notranslate"><span class="pre">nr</span></code> to each output record, containing the value of the built-in variable <code class="docutils literal notranslate"><span class="pre">NR</span></code> as of when that record was ingested.</p></li>
<li><p>Use the <strong>print</strong> or <strong>eprint</strong> keywords which immediately print an expression <em>directly to standard output or standard error</em>, respectively. Note that <code class="docutils literal notranslate"><span class="pre">dump</span></code>, <code class="docutils literal notranslate"><span class="pre">edump</span></code>, <code class="docutils literal notranslate"><span class="pre">print</span></code>, and <code class="docutils literal notranslate"><span class="pre">eprint</span></code> dont output records which participate in <code class="docutils literal notranslate"><span class="pre">then</span></code>-chaining; rather, theyre just immediate prints to stdout/stderr. The <code class="docutils literal notranslate"><span class="pre">printn</span></code> and <code class="docutils literal notranslate"><span class="pre">eprintn</span></code> keywords are the same except that they dont print final newlines. Additionally, you can print to a specified file instead of stdout/stderr.</p></li>
<li><p>Use the <strong>dump</strong> or <strong>edump</strong> keywords, which <em>immediately print all out-of-stream variables as a JSON data structure to the standard output or standard error</em> (respectively).</p></li>
<li><p>Use <strong>tee</strong> which formats the current stream record (not just an arbitrary string as with <strong>print</strong>) to a specific file.</p></li>
<li><p>Use <strong>emit</strong>/<strong>emitp</strong>/<strong>emitf</strong> to send out-of-stream variables current values to the output record stream, e.g. <code class="docutils literal notranslate"><span class="pre">&#64;sum</span> <span class="pre">+=</span> <span class="pre">$x;</span> <span class="pre">emit</span> <span class="pre">&#64;sum</span></code> which produces an extra output record such as <code class="docutils literal notranslate"><span class="pre">sum=3.1648382</span></code>.</p></li>
</ul>
<p>For the first two options you are populating the output-records stream which feeds into the next verb in a <code class="docutils literal notranslate"><span class="pre">then</span></code>-chain (if any), or which otherwise is formatted for output using <code class="docutils literal notranslate"><span class="pre">--o...</span></code> flags.</p>
<p>For the last three options you are sending output directly to standard output, standard error, or a file.</p>
<div class="section" id="print-statements">
<span id="reference-dsl-print-statements"></span><h3>Print statements<a class="headerlink" href="#print-statements" title="Permalink to this headline"></a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">print</span></code> statement is perhaps self-explanatory, but with a few light caveats:</p>
<ul class="simple">
<li><p>There are four variants: <code class="docutils literal notranslate"><span class="pre">print</span></code> goes to stdout with final newline, <code class="docutils literal notranslate"><span class="pre">printn</span></code> goes to stdout without final newline (you can include one using “n” in your output string), <code class="docutils literal notranslate"><span class="pre">eprint</span></code> goes to stderr with final newline, and <code class="docutils literal notranslate"><span class="pre">eprintn</span></code> goes to stderr without final newline.</p></li>
<li><p>Output goes directly to stdout/stderr, respectively: data produced this way do not go downstream to the next verb in a <code class="docutils literal notranslate"><span class="pre">then</span></code>-chain. (Use <code class="docutils literal notranslate"><span class="pre">emit</span></code> for that.)</p></li>
<li><p>Print statements are for strings (<code class="docutils literal notranslate"><span class="pre">print</span> <span class="pre">&quot;hello&quot;</span></code>), or things which can be made into strings: numbers (<code class="docutils literal notranslate"><span class="pre">print</span> <span class="pre">3</span></code>, <code class="docutils literal notranslate"><span class="pre">print</span> <span class="pre">$a</span> <span class="pre">+</span> <span class="pre">$b</span></code>, or concatenations thereof (<code class="docutils literal notranslate"><span class="pre">print</span> <span class="pre">&quot;a</span> <span class="pre">+</span> <span class="pre">b</span> <span class="pre">=</span> <span class="pre">&quot;</span> <span class="pre">.</span> <span class="pre">($a</span> <span class="pre">+</span> <span class="pre">$b)</span></code>). Maps (in <code class="docutils literal notranslate"><span class="pre">$*</span></code>, map-valued out-of-stream or local variables, and map literals) arent convertible into strings. If you print a map, you get <code class="docutils literal notranslate"><span class="pre">{is-a-map}</span></code> as output. Please use <code class="docutils literal notranslate"><span class="pre">dump</span></code> to print maps.</p></li>
<li><p>You can redirect print output to a file: <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">--from</span> <span class="pre">myfile.dat</span> <span class="pre">put</span> <span class="pre">'print</span> <span class="pre">&gt;</span> <span class="pre">&quot;tap.txt&quot;,</span> <span class="pre">$x'</span></code> <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">--from</span> <span class="pre">myfile.dat</span> <span class="pre">put</span> <span class="pre">'o=$*;</span> <span class="pre">print</span> <span class="pre">&gt;</span> <span class="pre">$a.&quot;.txt&quot;,</span> <span class="pre">$x'</span></code>.</p></li>
<li><p>See also <a class="reference internal" href="#reference-dsl-redirected-output-statements"><span class="std std-ref">Redirected-output statements</span></a> for examples.</p></li>
</ul>
</div>
<div class="section" id="dump-statements">
<span id="reference-dsl-dump-statements"></span><h3>Dump statements<a class="headerlink" href="#dump-statements" title="Permalink to this headline"></a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">dump</span></code> statement is for printing expressions, including maps, directly to stdout/stderr, respectively:</p>
<ul class="simple">
<li><p>There are two variants: <code class="docutils literal notranslate"><span class="pre">dump</span></code> prints to stdout; <code class="docutils literal notranslate"><span class="pre">edump</span></code> prints to stderr.</p></li>
<li><p>Output goes directly to stdout/stderr, respectively: data produced this way do not go downstream to the next verb in a <code class="docutils literal notranslate"><span class="pre">then</span></code>-chain. (Use <code class="docutils literal notranslate"><span class="pre">emit</span></code> for that.)</p></li>
<li><p>You can use <code class="docutils literal notranslate"><span class="pre">dump</span></code> to output single strings, numbers, or expressions including map-valued data. Map-valued data are printed as JSON. Miller allows string and integer keys in its map literals while JSON allows only string keys, so use <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span> <span class="pre">--jknquoteint</span></code> if you want integer-valued map keys not double-quoted.</p></li>
<li><p>If you use <code class="docutils literal notranslate"><span class="pre">dump</span></code> (or <code class="docutils literal notranslate"><span class="pre">edump</span></code>) with no arguments, you get a JSON structure representing the current values of all out-of-stream variables.</p></li>
<li><p>As with <code class="docutils literal notranslate"><span class="pre">print</span></code>, you can redirect output to files.</p></li>
<li><p>See also <a class="reference internal" href="#reference-dsl-redirected-output-statements"><span class="std std-ref">Redirected-output statements</span></a> for examples.</p></li>
</ul>
</div>
<div class="section" id="tee-statements">
<h3>Tee statements<a class="headerlink" href="#tee-statements" title="Permalink to this headline"></a></h3>
<p>Records produced by a <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code> go downstream to the next verb in your <code class="docutils literal notranslate"><span class="pre">then</span></code>-chain, if any, or otherwise to standard output. If you want to additionally copy out records to files, you can do that using <code class="docutils literal notranslate"><span class="pre">tee</span></code>.</p>
<p>The syntax is, by example, <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">--from</span> <span class="pre">myfile.dat</span> <span class="pre">put</span> <span class="pre">'tee</span> <span class="pre">&gt;</span> <span class="pre">&quot;tap.dat&quot;,</span> <span class="pre">$*'</span> <span class="pre">then</span> <span class="pre">sort</span> <span class="pre">-n</span> <span class="pre">index</span></code>. First is <code class="docutils literal notranslate"><span class="pre">tee</span> <span class="pre">&gt;</span></code>, then the filename expression (which can be an expression such as <code class="docutils literal notranslate"><span class="pre">&quot;tap.&quot;.$a.&quot;.dat&quot;</span></code>), then a comma, then <code class="docutils literal notranslate"><span class="pre">$*</span></code>. (Nothing else but <code class="docutils literal notranslate"><span class="pre">$*</span></code> is teeable.)</p>
<p>See also <a class="reference internal" href="#reference-dsl-redirected-output-statements"><span class="std std-ref">Redirected-output statements</span></a> for examples.</p>
</div>
<div class="section" id="redirected-output-statements">
<span id="reference-dsl-redirected-output-statements"></span><h3>Redirected-output statements<a class="headerlink" href="#redirected-output-statements" title="Permalink to this headline"></a></h3>
<p>The <strong>print</strong>, <strong>dump</strong> <strong>tee</strong>, <strong>emitf</strong>, <strong>emit</strong>, and <strong>emitp</strong> keywords all allow you to redirect output to one or more files or pipe-to commands. The filenames/commands are strings which can be constructed using record-dependent values, so you can do things like splitting a table into multiple files, one for each account ID, and so on.</p>
<p>Details:</p>
<ul class="simple">
<li><p>The <code class="docutils literal notranslate"><span class="pre">print</span></code> and <code class="docutils literal notranslate"><span class="pre">dump</span></code> keywords produce output immediately to standard output, or to specified file(s) or pipe-to command if present.</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --help-keyword print
print: prints expression immediately to stdout.
Example: mlr --from f.dat put -q &#39;print &quot;The sum of x and y is &quot;.($x+$y)&#39;
Example: mlr --from f.dat put -q &#39;for (k, v in $*) { print k . &quot; =&gt; &quot; . v }&#39;
Example: mlr --from f.dat put &#39;(NR % 1000 == 0) { print &gt; stderr, &quot;Checkpoint &quot;.NR}&#39;
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --help-keyword dump
dump: prints all currently defined out-of-stream variables immediately
to stdout as JSON.
With &gt;, &gt;&gt;, or |, the data do not become part of the output record stream but
are instead redirected.
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
Example: mlr --from f.dat put -q &#39;@v[NR]=$*; end { dump }&#39;
Example: mlr --from f.dat put -q &#39;@v[NR]=$*; end { dump &gt; &quot;mytap.dat&quot;}&#39;
Example: mlr --from f.dat put -q &#39;@v[NR]=$*; end { dump &gt;&gt; &quot;mytap.dat&quot;}&#39;
Example: mlr --from f.dat put -q &#39;@v[NR]=$*; end { dump | &quot;jq .[]&quot;}&#39;
</pre></div>
</div>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code> sends the current record (possibly modified by the <code class="docutils literal notranslate"><span class="pre">put</span></code> expression) to the output record stream. Records are then input to the following verb in a <code class="docutils literal notranslate"><span class="pre">then</span></code>-chain (if any), else printed to standard output (unless <code class="docutils literal notranslate"><span class="pre">put</span> <span class="pre">-q</span></code>). The <strong>tee</strong> keyword <em>additionally</em> writes the output record to specified file(s) or pipe-to command, or immediately to <code class="docutils literal notranslate"><span class="pre">stdout</span></code>/<code class="docutils literal notranslate"><span class="pre">stderr</span></code>.</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --help-keyword tee
tee: prints the current record to specified file.
This is an immediate print to the specified file (except for pprint format
which of course waits until the end of the input stream to format all output).
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
You can use any of the output-format command-line flags, e.g. --ocsv, --ofs,
etc., to control the format of the output. See also mlr -h.
emit with redirect and tee with redirect are identical, except tee can only
output $*.
Example: mlr --from f.dat put &#39;tee &gt; &quot;/tmp/data-&quot;.$a, $*&#39;
Example: mlr --from f.dat put &#39;tee &gt;&gt; &quot;/tmp/data-&quot;.$a.$b, $*&#39;
Example: mlr --from f.dat put &#39;tee &gt; stderr, $*&#39;
Example: mlr --from f.dat put -q &#39;tee | &quot;tr [a-z\] [A-Z\]&quot;, $*&#39;
Example: mlr --from f.dat put -q &#39;tee | &quot;tr [a-z\] [A-Z\] &gt; /tmp/data-&quot;.$a, $*&#39;
Example: mlr --from f.dat put -q &#39;tee | &quot;gzip &gt; /tmp/data-&quot;.$a.&quot;.gz&quot;, $*&#39;
Example: mlr --from f.dat put -q --ojson &#39;tee | &quot;gzip &gt; /tmp/data-&quot;.$a.&quot;.gz&quot;, $*&#39;
</pre></div>
</div>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code>s <code class="docutils literal notranslate"><span class="pre">emitf</span></code>, <code class="docutils literal notranslate"><span class="pre">emitp</span></code>, and <code class="docutils literal notranslate"><span class="pre">emit</span></code> send out-of-stream variables to the output record stream. These are then input to the following verb in a <code class="docutils literal notranslate"><span class="pre">then</span></code>-chain (if any), else printed to standard output. When redirected with <code class="docutils literal notranslate"><span class="pre">&gt;</span></code>, <code class="docutils literal notranslate"><span class="pre">&gt;&gt;</span></code>, or <code class="docutils literal notranslate"><span class="pre">|</span></code>, they <em>instead</em> write the out-of-stream variable(s) to specified file(s) or pipe-to command, or immediately to <code class="docutils literal notranslate"><span class="pre">stdout</span></code>/<code class="docutils literal notranslate"><span class="pre">stderr</span></code>.</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --help-keyword emitf
emitf: inserts non-indexed out-of-stream variable(s) side-by-side into the
output record stream.
With &gt;, &gt;&gt;, or |, the data do not become part of the output record stream but
are instead redirected.
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
You can use any of the output-format command-line flags, e.g. --ocsv, --ofs,
etc., to control the format of the output if the output is redirected. See also mlr -h.
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf @a&#39;
Example: mlr --from f.dat put --oxtab &#39;@a=$i;@b+=$x;@c+=$y; emitf &gt; &quot;tap-&quot;.$i.&quot;.dat&quot;, @a&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf &gt; &quot;mytap.dat&quot;, @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf &gt;&gt; &quot;mytap.dat&quot;, @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf &gt; stderr, @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf | &quot;grep somepattern&quot;, @a, @b, @c&#39;
Example: mlr --from f.dat put &#39;@a=$i;@b+=$x;@c+=$y; emitf | &quot;grep somepattern &gt; mytap.dat&quot;, @a, @b, @c&#39;
Please see http://johnkerl.org/miller/doc for more information.
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --help-keyword emitp
emitp: inserts an out-of-stream variable into the output record stream.
Hashmap indices present in the data but not slotted by emitp arguments are
output concatenated with &quot;:&quot;.
With &gt;, &gt;&gt;, or |, the data do not become part of the output record stream but
are instead redirected.
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
You can use any of the output-format command-line flags, e.g. --ocsv, --ofs,
etc., to control the format of the output if the output is redirected. See also mlr -h.
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp @sums&#39;
Example: mlr --from f.dat put --opprint &#39;@sums[$a][$b]+=$x; emitp &gt; &quot;tap-&quot;.$a.$b.&quot;.dat&quot;, @sums&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp @sums, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp &gt; &quot;mytap.dat&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp &gt;&gt; &quot;mytap.dat&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp | &quot;gzip &gt; mytap.dat.gz&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp &gt; stderr, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emitp | &quot;grep somepattern&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Please see http://johnkerl.org/miller/doc for more information.
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --help-keyword emit
emit: inserts an out-of-stream variable into the output record stream. Hashmap
indices present in the data but not slotted by emit arguments are not output.
With &gt;, &gt;&gt;, or |, the data do not become part of the output record stream but
are instead redirected.
The &gt; and &gt;&gt; are for write and append, as in the shell, but (as with awk) the
file-overwrite for &gt; is on first write, not per record. The | is for piping to
a process which will process the data. There will be one open file for each
distinct file name (for &gt; and &gt;&gt;) or one subordinate process for each distinct
value of the piped-to command (for |). Output-formatting flags are taken from
the main command line.
You can use any of the output-format command-line flags, e.g. --ocsv, --ofs,
etc., to control the format of the output if the output is redirected. See also mlr -h.
Example: mlr --from f.dat put &#39;emit &gt; &quot;/tmp/data-&quot;.$a, $*&#39;
Example: mlr --from f.dat put &#39;emit &gt; &quot;/tmp/data-&quot;.$a, mapexcept($*, &quot;a&quot;)&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit @sums&#39;
Example: mlr --from f.dat put --ojson &#39;@sums[$a][$b]+=$x; emit &gt; &quot;tap-&quot;.$a.$b.&quot;.dat&quot;, @sums&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit @sums, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit &gt; &quot;mytap.dat&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit &gt;&gt; &quot;mytap.dat&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit | &quot;gzip &gt; mytap.dat.gz&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit &gt; stderr, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Example: mlr --from f.dat put &#39;@sums[$a][$b]+=$x; emit | &quot;grep somepattern&quot;, @*, &quot;index1&quot;, &quot;index2&quot;&#39;
Please see http://johnkerl.org/miller/doc for more information.
</pre></div>
</div>
</div>
<div class="section" id="emit-statements">
<span id="reference-dsl-emit-statements"></span><h3>Emit statements<a class="headerlink" href="#emit-statements" title="Permalink to this headline"></a></h3>
<p>There are three variants: <code class="docutils literal notranslate"><span class="pre">emitf</span></code>, <code class="docutils literal notranslate"><span class="pre">emit</span></code>, and <code class="docutils literal notranslate"><span class="pre">emitp</span></code>. Keep in mind that out-of-stream variables are a nested, multi-level hashmap (directly viewable as JSON using <code class="docutils literal notranslate"><span class="pre">dump</span></code>), whereas Miller output records are lists of single-level key-value pairs. The three emit variants allow you to control how the multilevel hashmaps are flatten down to output records. You can emit any map-valued expression, including <code class="docutils literal notranslate"><span class="pre">$*</span></code>, map-valued out-of-stream variables, the entire out-of-stream-variable collection <code class="docutils literal notranslate"><span class="pre">&#64;*</span></code>, map-valued local variables, map literals, or map-valued function return values.</p>
<p>Use <strong>emitf</strong> to output several out-of-stream variables side-by-side in the same output record. For <code class="docutils literal notranslate"><span class="pre">emitf</span></code> these mustnt have indexing using <code class="docutils literal notranslate"><span class="pre">&#64;name[...]</span></code>. Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@count += 1; @x_sum += $x; @y_sum += $y; end { emitf @count, @x_sum, @y_sum}&#39; data/small
count=5,x_sum=2.264762,y_sum=2.585086
</pre></div>
</div>
<p>Use <strong>emit</strong> to output an out-of-stream variable. If its non-indexed youll get a simple key-value pair:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum += $x; end { dump }&#39; data/small
{
&quot;sum&quot;: 2.264762
}
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum += $x; end { emit @sum }&#39; data/small
sum=2.264762
</pre></div>
</div>
<p>If its indexed then use as many names after <code class="docutils literal notranslate"><span class="pre">emit</span></code> as there are indices:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a] += $x; end { dump }&#39; data/small
{
&quot;sum&quot;: {
&quot;pan&quot;: 0.346790,
&quot;eks&quot;: 1.140079,
&quot;wye&quot;: 0.777892
}
}
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a] += $x; end { emit @sum, &quot;a&quot; }&#39; data/small
a=pan,sum=0.346790
a=eks,sum=1.140079
a=wye,sum=0.777892
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b] += $x; end { dump }&#39; data/small
{
&quot;sum&quot;: {
&quot;pan&quot;: {
&quot;pan&quot;: 0.346790
},
&quot;eks&quot;: {
&quot;pan&quot;: 0.758680,
&quot;wye&quot;: 0.381399
},
&quot;wye&quot;: {
&quot;wye&quot;: 0.204603,
&quot;pan&quot;: 0.573289
}
}
}
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b] += $x; end { emit @sum, &quot;a&quot;, &quot;b&quot; }&#39; data/small
a=pan,b=pan,sum=0.346790
a=eks,b=pan,sum=0.758680
a=eks,b=wye,sum=0.381399
a=wye,b=wye,sum=0.204603
a=wye,b=pan,sum=0.573289
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b][$i] += $x; end { dump }&#39; data/small
{
&quot;sum&quot;: {
&quot;pan&quot;: {
&quot;pan&quot;: {
&quot;1&quot;: 0.346790
}
},
&quot;eks&quot;: {
&quot;pan&quot;: {
&quot;2&quot;: 0.758680
},
&quot;wye&quot;: {
&quot;4&quot;: 0.381399
}
},
&quot;wye&quot;: {
&quot;wye&quot;: {
&quot;3&quot;: 0.204603
},
&quot;pan&quot;: {
&quot;5&quot;: 0.573289
}
}
}
}
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b][$i] += $x; end { emit @sum, &quot;a&quot;, &quot;b&quot;, &quot;i&quot; }&#39; data/small
a=pan,b=pan,i=1,sum=0.346790
a=eks,b=pan,i=2,sum=0.758680
a=eks,b=wye,i=4,sum=0.381399
a=wye,b=wye,i=3,sum=0.204603
a=wye,b=pan,i=5,sum=0.573289
</pre></div>
</div>
<p>Now for <strong>emitp</strong>: if you have as many names following <code class="docutils literal notranslate"><span class="pre">emit</span></code> as there are levels in the out-of-stream variables hashmap, then <code class="docutils literal notranslate"><span class="pre">emit</span></code> and <code class="docutils literal notranslate"><span class="pre">emitp</span></code> do the same thing. Where they differ is when you dont specify as many names as there are hashmap levels. In this case, Miller needs to flatten multiple map indices down to output-record keys: <code class="docutils literal notranslate"><span class="pre">emitp</span></code> includes full prefixing (hence the <code class="docutils literal notranslate"><span class="pre">p</span></code> in <code class="docutils literal notranslate"><span class="pre">emitp</span></code>) while <code class="docutils literal notranslate"><span class="pre">emit</span></code> takes the deepest hashmap key as the output-record key:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b] += $x; end { dump }&#39; data/small
{
&quot;sum&quot;: {
&quot;pan&quot;: {
&quot;pan&quot;: 0.346790
},
&quot;eks&quot;: {
&quot;pan&quot;: 0.758680,
&quot;wye&quot;: 0.381399
},
&quot;wye&quot;: {
&quot;wye&quot;: 0.204603,
&quot;pan&quot;: 0.573289
}
}
}
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b] += $x; end { emit @sum, &quot;a&quot; }&#39; data/small
a=pan,pan=0.346790
a=eks,pan=0.758680,wye=0.381399
a=wye,wye=0.204603,pan=0.573289
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b] += $x; end { emit @sum }&#39; data/small
pan=0.346790
pan=0.758680,wye=0.381399
wye=0.204603,pan=0.573289
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b] += $x; end { emitp @sum, &quot;a&quot; }&#39; data/small
a=pan,sum:pan=0.346790
a=eks,sum:pan=0.758680,sum:wye=0.381399
a=wye,sum:wye=0.204603,sum:pan=0.573289
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b] += $x; end { emitp @sum }&#39; data/small
sum:pan:pan=0.346790,sum:eks:pan=0.758680,sum:eks:wye=0.381399,sum:wye:wye=0.204603,sum:wye:pan=0.573289
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --oxtab put -q &#39;@sum[$a][$b] += $x; end { emitp @sum }&#39; data/small
sum:pan:pan 0.346790
sum:eks:pan 0.758680
sum:eks:wye 0.381399
sum:wye:wye 0.204603
sum:wye:pan 0.573289
</pre></div>
</div>
<p>Use <strong>oflatsep</strong> to specify the character which joins multilevel
keys for <code class="docutils literal notranslate"><span class="pre">emitp</span></code> (it defaults to a colon):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q --oflatsep / &#39;@sum[$a][$b] += $x; end { emitp @sum, &quot;a&quot; }&#39; data/small
a=pan,sum/pan=0.346790
a=eks,sum/pan=0.758680,sum/wye=0.381399
a=wye,sum/wye=0.204603,sum/pan=0.573289
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q --oflatsep / &#39;@sum[$a][$b] += $x; end { emitp @sum }&#39; data/small
sum/pan/pan=0.346790,sum/eks/pan=0.758680,sum/eks/wye=0.381399,sum/wye/wye=0.204603,sum/wye/pan=0.573289
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --oxtab put -q --oflatsep / &#39;@sum[$a][$b] += $x; end { emitp @sum }&#39; data/small
sum/pan/pan 0.346790
sum/eks/pan 0.758680
sum/eks/wye 0.381399
sum/wye/wye 0.204603
sum/wye/pan 0.573289
</pre></div>
</div>
</div>
<div class="section" id="multi-emit-statements">
<h3>Multi-emit statements<a class="headerlink" href="#multi-emit-statements" title="Permalink to this headline"></a></h3>
<p>You can emit <strong>multiple map-valued expressions side-by-side</strong> by
including their names in parentheses:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/medium --opprint put -q &#39;
@x_count[$a][$b] += 1;
@x_sum[$a][$b] += $x;
end {
for ((a, b), _ in @x_count) {
@x_mean[a][b] = @x_sum[a][b] / @x_count[a][b]
}
emit (@x_sum, @x_count, @x_mean), &quot;a&quot;, &quot;b&quot;
}
&#39;
a b x_sum x_count x_mean
pan pan 219.185129 427 0.513314
pan wye 198.432931 395 0.502362
pan eks 216.075228 429 0.503672
pan hat 205.222776 417 0.492141
pan zee 205.097518 413 0.496604
eks pan 179.963030 371 0.485076
eks wye 196.945286 407 0.483895
eks zee 176.880365 357 0.495463
eks eks 215.916097 413 0.522799
eks hat 208.783171 417 0.500679
wye wye 185.295850 377 0.491501
wye pan 195.847900 392 0.499612
wye hat 212.033183 426 0.497730
wye zee 194.774048 385 0.505907
wye eks 204.812961 386 0.530604
zee pan 202.213804 389 0.519830
zee wye 233.991394 455 0.514267
zee eks 190.961778 391 0.488393
zee zee 206.640635 403 0.512756
zee hat 191.300006 409 0.467726
hat wye 208.883010 423 0.493813
hat zee 196.349450 385 0.509999
hat eks 189.006793 389 0.485879
hat hat 182.853532 381 0.479931
hat pan 168.553807 363 0.464336
</pre></div>
</div>
<p>What this does is walk through the first out-of-stream variable (<code class="docutils literal notranslate"><span class="pre">&#64;x_sum</span></code> in this example) as usual, then for each keylist found (e.g. <code class="docutils literal notranslate"><span class="pre">pan,wye</span></code>), include the values for the remaining out-of-stream variables (here, <code class="docutils literal notranslate"><span class="pre">&#64;x_count</span></code> and <code class="docutils literal notranslate"><span class="pre">&#64;x_mean</span></code>). You should use this when all out-of-stream variables in the emit statement have <strong>the same shape and the same keylists</strong>.</p>
</div>
<div class="section" id="emit-all-statements">
<h3>Emit-all statements<a class="headerlink" href="#emit-all-statements" title="Permalink to this headline"></a></h3>
<p>Use <strong>emit all</strong> (or <code class="docutils literal notranslate"><span class="pre">emit</span> <span class="pre">&#64;*</span></code> which is synonymous) to output all out-of-stream variables. You can use the following idiom to get various accumulators output side-by-side (reminiscent of <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">stats1</span></code>):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small --opprint put -q &#39;@v[$a][$b][&quot;sum&quot;] += $x; @v[$a][$b][&quot;count&quot;] += 1; end{emit @*,&quot;a&quot;,&quot;b&quot;}&#39;
a b sum count
pan pan 0.346790 1
eks pan 0.758680 1
eks wye 0.381399 1
wye wye 0.204603 1
wye pan 0.573289 1
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small --opprint put -q &#39;@sum[$a][$b] += $x; @count[$a][$b] += 1; end{emit @*,&quot;a&quot;,&quot;b&quot;}&#39;
a b sum
pan pan 0.346790
eks pan 0.758680
eks wye 0.381399
wye wye 0.204603
wye pan 0.573289
a b count
pan pan 1
eks pan 1
eks wye 1
wye wye 1
wye pan 1
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --from data/small --opprint put -q &#39;@sum[$a][$b] += $x; @count[$a][$b] += 1; end{emit (@sum, @count),&quot;a&quot;,&quot;b&quot;}&#39;
a b sum count
pan pan 0.346790 1
eks pan 0.758680 1
eks wye 0.381399 1
wye wye 0.204603 1
wye pan 0.573289 1
</pre></div>
</div>
</div>
</div>
<div class="section" id="unset-statements">
<h2>Unset statements<a class="headerlink" href="#unset-statements" title="Permalink to this headline"></a></h2>
<p>You can clear a map key by assigning the empty string as its value: <code class="docutils literal notranslate"><span class="pre">$x=&quot;&quot;</span></code> or <code class="docutils literal notranslate"><span class="pre">&#64;x=&quot;&quot;</span></code>. Using <code class="docutils literal notranslate"><span class="pre">unset</span></code> you can remove the key entirely. Examples:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cat data/small
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;unset $x, $a&#39; data/small
b=pan,i=1,y=0.7268028627434533
b=pan,i=2,y=0.5221511083334797
b=wye,i=3,y=0.33831852551664776
b=wye,i=4,y=0.13418874328430463
b=pan,i=5,y=0.8636244699032729
</pre></div>
</div>
<p>This can also be done, of course, using <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">cut</span> <span class="pre">-x</span></code>. You can also clear out-of-stream or local variables, at the base name level, or at an indexed sublevel:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b] += $x; end { dump; unset @sum; dump }&#39; data/small
{
&quot;sum&quot;: {
&quot;pan&quot;: {
&quot;pan&quot;: 0.346790
},
&quot;eks&quot;: {
&quot;pan&quot;: 0.758680,
&quot;wye&quot;: 0.381399
},
&quot;wye&quot;: {
&quot;wye&quot;: 0.204603,
&quot;pan&quot;: 0.573289
}
}
}
{
}
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put -q &#39;@sum[$a][$b] += $x; end { dump; unset @sum[&quot;eks&quot;]; dump }&#39; data/small
{
&quot;sum&quot;: {
&quot;pan&quot;: {
&quot;pan&quot;: 0.346790
},
&quot;eks&quot;: {
&quot;pan&quot;: 0.758680,
&quot;wye&quot;: 0.381399
},
&quot;wye&quot;: {
&quot;wye&quot;: 0.204603,
&quot;pan&quot;: 0.573289
}
}
}
{
&quot;sum&quot;: {
&quot;pan&quot;: {
&quot;pan&quot;: 0.346790
},
&quot;wye&quot;: {
&quot;wye&quot;: 0.204603,
&quot;pan&quot;: 0.573289
}
}
}
</pre></div>
</div>
<p>If you use <code class="docutils literal notranslate"><span class="pre">unset</span> <span class="pre">all</span></code> (or <code class="docutils literal notranslate"><span class="pre">unset</span> <span class="pre">&#64;*</span></code> which is synonymous), that will unset all out-of-stream variables which have been defined up to that point.</p>
</div>
<div class="section" id="filter-statements">
<h2>Filter statements<a class="headerlink" href="#filter-statements" title="Permalink to this headline"></a></h2>
<p>You can use <code class="docutils literal notranslate"><span class="pre">filter</span></code> within <code class="docutils literal notranslate"><span class="pre">put</span></code>. In fact, the following two are synonymous:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr filter &#39;NR==2 || NR==3&#39; data/small
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;filter NR==2 || NR==3&#39; data/small
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
</pre></div>
</div>
<p>The former, of course, is much easier to type. But the latter allows you to define more complex expressions for the filter, and/or do other things in addition to the filter:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;@running_sum += $x; filter @running_sum &gt; 1.3&#39; data/small
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr put &#39;$z = $x * $y; filter $z &gt; 0.3&#39; data/small
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797,z=0.396146
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729,z=0.495106
</pre></div>
</div>
</div>
<div class="section" id="built-in-functions-for-filter-and-put-summary">
<h2>Built-in functions for filter and put, summary<a class="headerlink" href="#built-in-functions-for-filter-and-put-summary" title="Permalink to this headline"></a></h2>
<table class="docutils align-default">
<colgroup>
<col style="width: 56%" />
<col style="width: 24%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p><code class="docutils literal notranslate"><span class="pre">Name</span></code></p></th>
<th class="head"><p>Class</p></th>
<th class="head"><p>#Args</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">+</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">+</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">-</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">-</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">*</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">/</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">//</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">.+</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">.+</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">.-</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">.-</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">.*</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">./</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">.//</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">%</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">**</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">|</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">^</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&amp;</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">~</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&lt;&lt;</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&gt;&gt;</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">bitcount</span></code></p></td>
<td><p>arithmetic</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">==</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">!=</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">=~</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">!=~</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&gt;</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&gt;=</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&lt;</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&lt;=</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&amp;&amp;</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">||</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">^^</span></code></p></td>
<td><p>boolean</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">!</span></code></p></td>
<td><p>boolean</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">?</span> <span class="pre">:</span></code></p></td>
<td><p>boolean</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">.</span></code></p></td>
<td><p>string</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">gsub</span></code></p></td>
<td><p>string</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">regextract</span></code></p></td>
<td><p>string</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">regextract_or_else</span></code></p></td>
<td><p>string</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">strlen</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">sub</span></code></p></td>
<td><p>string</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">ssub</span></code></p></td>
<td><p>string</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">substr</span></code></p></td>
<td><p>string</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">tolower</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">toupper</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">truncate</span></code></p></td>
<td><p>string</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">capitalize</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">lstrip</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">rstrip</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">strip</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">collapse_whitespace</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">clean_whitespace</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">system</span></code></p></td>
<td><p>string</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">abs</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">acos</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">acosh</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">asin</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">asinh</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">atan</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">atan2</span></code></p></td>
<td><p>math</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">atanh</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">cbrt</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">ceil</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">cos</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">cosh</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">erf</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">erfc</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">exp</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">expm1</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">floor</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">invqnorm</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">log</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">log10</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">log1p</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">logifit</span></code></p></td>
<td><p>math</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">madd</span></code></p></td>
<td><p>math</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">max</span></code></p></td>
<td><p>math</p></td>
<td><p>variadic</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">mexp</span></code></p></td>
<td><p>math</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">min</span></code></p></td>
<td><p>math</p></td>
<td><p>variadic</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">mmul</span></code></p></td>
<td><p>math</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">msub</span></code></p></td>
<td><p>math</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">pow</span></code></p></td>
<td><p>math</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">qnorm</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">round</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">roundm</span></code></p></td>
<td><p>math</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">sgn</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">sin</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">sinh</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">sqrt</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">tan</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">tanh</span></code></p></td>
<td><p>math</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">urand</span></code></p></td>
<td><p>math</p></td>
<td><p>0</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">urandrange</span></code></p></td>
<td><p>math</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">urand32</span></code></p></td>
<td><p>math</p></td>
<td><p>0</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">urandint</span></code></p></td>
<td><p>math</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">dhms2fsec</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">dhms2sec</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">fsec2dhms</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">fsec2hms</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">gmt2sec</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">localtime2sec</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">hms2fsec</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">hms2sec</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">sec2dhms</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">sec2gmt</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">sec2gmt</span></code></p></td>
<td><p>time</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">sec2gmtdate</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">sec2localtime</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">sec2localtime</span></code></p></td>
<td><p>time</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">sec2localdate</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">sec2hms</span></code></p></td>
<td><p>time</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">strftime</span></code></p></td>
<td><p>time</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">strftime_local</span></code></p></td>
<td><p>time</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">strptime</span></code></p></td>
<td><p>time</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">strptime_local</span></code></p></td>
<td><p>time</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">systime</span></code></p></td>
<td><p>time</p></td>
<td><p>0</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_absent</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_bool</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_boolean</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_empty</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_empty_map</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_float</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_int</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_map</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_nonempty_map</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_not_empty</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_not_map</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_not_null</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_null</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_numeric</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">is_present</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">is_string</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_absent</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_bool</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_boolean</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_empty</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_empty_map</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_float</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_int</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_map</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_nonempty_map</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_not_empty</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_not_map</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_not_null</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_null</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_numeric</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_present</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">asserting_string</span></code></p></td>
<td><p>typing</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">boolean</span></code></p></td>
<td><p>conversion</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p></td>
<td><p>conversion</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">fmtnum</span></code></p></td>
<td><p>conversion</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">hexfmt</span></code></p></td>
<td><p>conversion</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">int</span></code></p></td>
<td><p>conversion</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">string</span></code></p></td>
<td><p>conversion</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">typeof</span></code></p></td>
<td><p>conversion</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">depth</span></code></p></td>
<td><p>maps</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">haskey</span></code></p></td>
<td><p>maps</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">joink</span></code></p></td>
<td><p>maps</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">joinkv</span></code></p></td>
<td><p>maps</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">joinv</span></code></p></td>
<td><p>maps</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">leafcount</span></code></p></td>
<td><p>maps</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">length</span></code></p></td>
<td><p>maps</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">mapdiff</span></code></p></td>
<td><p>maps</p></td>
<td><p>variadic</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">mapexcept</span></code></p></td>
<td><p>maps</p></td>
<td><p>variadic</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">mapselect</span></code></p></td>
<td><p>maps</p></td>
<td><p>variadic</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">mapsum</span></code></p></td>
<td><p>maps</p></td>
<td><p>variadic</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">splitkv</span></code></p></td>
<td><p>maps</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">splitkvx</span></code></p></td>
<td><p>maps</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">splitnv</span></code></p></td>
<td><p>maps</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">splitnvx</span></code></p></td>
<td><p>maps</p></td>
<td><p>2</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="built-in-functions-for-filter-and-put">
<h2>Built-in functions for filter and put<a class="headerlink" href="#built-in-functions-for-filter-and-put" title="Permalink to this headline"></a></h2>
<p>Each function takes a specific number of arguments, as shown below, except for functions marked as variadic such as <code class="docutils literal notranslate"><span class="pre">min</span></code> and <code class="docutils literal notranslate"><span class="pre">max</span></code>. (The latter compute min and max of any number of numerical arguments.) There is no notion of optional or default-on-absent arguments. All argument-passing is positional rather than by name; arguments are passed by value, not by reference.</p>
<p>You can get a list of all functions using <strong>mlr -F</strong>.</p>
<div class="section" id="reference-dsl-plus">
<span id="id1"></span><h3>+<a class="headerlink" href="#reference-dsl-plus" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">+</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Addition.</span>
<span class="o">+</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=1): Unary plus.</span>
</pre></div>
</div>
</div>
<div class="section" id="reference-dsl-minus">
<span id="id2"></span><h3>-<a class="headerlink" href="#reference-dsl-minus" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Subtraction.</span>
<span class="o">-</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=1): Unary minus.</span>
</pre></div>
</div>
</div>
<div class="section" id="reference-dsl-times">
<span id="id3"></span><h3>*<a class="headerlink" href="#reference-dsl-times" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">*</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Multiplication.</span>
</pre></div>
</div>
</div>
<div class="section" id="id4">
<h3>/<a class="headerlink" href="#id4" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">/</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Division.</span>
</pre></div>
</div>
</div>
<div class="section" id="id6">
<h3>//<a class="headerlink" href="#id6" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Integer division: rounds to negative (pythonic).</span>
</pre></div>
</div>
</div>
<div class="section" id="id7">
<span id="id8"></span><h3>.+<a class="headerlink" href="#id7" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.+</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Addition, with integer-to-integer overflow</span>
<span class="o">.+</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=1): Unary plus, with integer-to-integer overflow.</span>
</pre></div>
</div>
</div>
<div class="section" id="id9">
<span id="id10"></span><h3>.-<a class="headerlink" href="#id9" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.-</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Subtraction, with integer-to-integer overflow.</span>
<span class="o">.-</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=1): Unary minus, with integer-to-integer overflow.</span>
</pre></div>
</div>
</div>
<div class="section" id="id11">
<span id="id12"></span><h3>.*<a class="headerlink" href="#id11" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.*</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Multiplication, with integer-to-integer overflow.</span>
</pre></div>
</div>
</div>
<div class="section" id="id13">
<span id="id14"></span><h3>./<a class="headerlink" href="#id13" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Division, with integer-to-integer overflow.</span>
</pre></div>
</div>
</div>
<div class="section" id="id15">
<span id="id16"></span><h3>.//<a class="headerlink" href="#id15" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.//</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Integer division: rounds to negative (pythonic), with integer-to-integer overflow.</span>
</pre></div>
</div>
</div>
<div class="section" id="id18">
<h3>%<a class="headerlink" href="#id18" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">%</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Remainder; never negative-valued (pythonic).</span>
</pre></div>
</div>
</div>
<div class="section" id="reference-dsl-exponentiation">
<span id="id19"></span><h3>**<a class="headerlink" href="#reference-dsl-exponentiation" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">**</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Exponentiation; same as pow, but as an infix</span>
<span class="n">operator</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="reference-dsl-bitwise-or">
<span id="id20"></span><h3>|<a class="headerlink" href="#reference-dsl-bitwise-or" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">|</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Bitwise OR.</span>
</pre></div>
</div>
</div>
<div class="section" id="id22">
<h3>^<a class="headerlink" href="#id22" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">^</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Bitwise XOR.</span>
</pre></div>
</div>
</div>
<div class="section" id="id24">
<h3>&amp;<a class="headerlink" href="#id24" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&amp;</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Bitwise AND.</span>
</pre></div>
</div>
</div>
<div class="section" id="id26">
<h3>~<a class="headerlink" href="#id26" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">~</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=1): Bitwise NOT. Beware &#39;$y=~$x&#39; since =~ is the</span>
<span class="n">regex</span><span class="o">-</span><span class="n">match</span> <span class="n">operator</span><span class="p">:</span> <span class="k">try</span> <span class="s1">&#39;$y = ~$x&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="id28">
<h3>&lt;&lt;<a class="headerlink" href="#id28" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;&lt;</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Bitwise left-shift.</span>
</pre></div>
</div>
</div>
<div class="section" id="id30">
<h3>&gt;&gt;<a class="headerlink" href="#id30" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=2): Bitwise right-shift.</span>
</pre></div>
</div>
</div>
<div class="section" id="id32">
<h3>==<a class="headerlink" href="#id32" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">==</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): String/numeric equality. Mixing number and string</span>
<span class="n">results</span> <span class="ow">in</span> <span class="n">string</span> <span class="n">compare</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="id33">
<span id="id34"></span><h3>!=<a class="headerlink" href="#id33" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">!=</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): String/numeric inequality. Mixing number and string</span>
<span class="n">results</span> <span class="ow">in</span> <span class="n">string</span> <span class="n">compare</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="id35">
<span id="id36"></span><h3>=~<a class="headerlink" href="#id35" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">=~</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): String (left-hand side) matches regex (right-hand</span>
<span class="n">side</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;$name =~ &quot;^a.*b$&quot;&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="id37">
<span id="id38"></span><h3>!=~<a class="headerlink" href="#id37" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">!=~</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): String (left-hand side) does not match regex</span>
<span class="p">(</span><span class="n">right</span><span class="o">-</span><span class="n">hand</span> <span class="n">side</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;$name !=~ &quot;^a.*b$&quot;&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="id40">
<h3>&gt;<a class="headerlink" href="#id40" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): String/numeric greater-than. Mixing number and string</span>
<span class="n">results</span> <span class="ow">in</span> <span class="n">string</span> <span class="n">compare</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="id41">
<span id="id42"></span><h3>&gt;=<a class="headerlink" href="#id41" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;=</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): String/numeric greater-than-or-equals. Mixing number</span>
<span class="ow">and</span> <span class="n">string</span> <span class="n">results</span> <span class="ow">in</span> <span class="n">string</span> <span class="n">compare</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="id44">
<h3>&lt;<a class="headerlink" href="#id44" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): String/numeric less-than. Mixing number and string</span>
<span class="n">results</span> <span class="ow">in</span> <span class="n">string</span> <span class="n">compare</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="id45">
<span id="id46"></span><h3>&lt;=<a class="headerlink" href="#id45" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;=</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): String/numeric less-than-or-equals. Mixing number</span>
<span class="ow">and</span> <span class="n">string</span> <span class="n">results</span> <span class="ow">in</span> <span class="n">string</span> <span class="n">compare</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="id48">
<h3>&amp;&amp;<a class="headerlink" href="#id48" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&amp;&amp;</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): Logical AND.</span>
</pre></div>
</div>
</div>
<div class="section" id="id50">
<h3>||<a class="headerlink" href="#id50" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">||</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): Logical OR.</span>
</pre></div>
</div>
</div>
<div class="section" id="id52">
<h3>^^<a class="headerlink" href="#id52" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">^^</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">boolean</span> <span class="c1">#args=2): Logical XOR.</span>
</pre></div>
</div>
</div>
<div class="section" id="id54">
<h3>!<a class="headerlink" href="#id54" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>! (class=boolean #args=1): Logical negation.
</pre></div>
</div>
</div>
<div class="section" id="reference-dsl-question-mark-colon">
<span id="id55"></span><h3>?<a class="headerlink" href="#reference-dsl-question-mark-colon" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>? : (class=boolean #args=3): Ternary operator.
</pre></div>
</div>
</div>
<div class="section" id="id57">
<h3>.<a class="headerlink" href="#id57" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=2): String concatenation.</span>
</pre></div>
</div>
</div>
<div class="section" id="abs">
<span id="reference-dsl-abs"></span><h3>abs<a class="headerlink" href="#abs" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">abs</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Absolute value.</span>
</pre></div>
</div>
</div>
<div class="section" id="acos">
<span id="reference-dsl-acos"></span><h3>acos<a class="headerlink" href="#acos" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">acos</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Inverse trigonometric cosine.</span>
</pre></div>
</div>
</div>
<div class="section" id="acosh">
<span id="reference-dsl-acosh"></span><h3>acosh<a class="headerlink" href="#acosh" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">acosh</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Inverse hyperbolic cosine.</span>
</pre></div>
</div>
</div>
<div class="section" id="asin">
<span id="reference-dsl-asin"></span><h3>asin<a class="headerlink" href="#asin" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asin</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Inverse trigonometric sine.</span>
</pre></div>
</div>
</div>
<div class="section" id="asinh">
<span id="reference-dsl-asinh"></span><h3>asinh<a class="headerlink" href="#asinh" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asinh</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Inverse hyperbolic sine.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-absent">
<span id="reference-dsl-asserting-absent"></span><h3>asserting_absent<a class="headerlink" href="#asserting-absent" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_absent</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is absent in the input data, else</span>
<span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-bool">
<span id="reference-dsl-asserting-bool"></span><h3>asserting_bool<a class="headerlink" href="#asserting-bool" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_bool</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is present with boolean value, else</span>
<span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-boolean">
<span id="reference-dsl-asserting-boolean"></span><h3>asserting_boolean<a class="headerlink" href="#asserting-boolean" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_boolean</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is present with boolean value, else</span>
<span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-empty">
<span id="reference-dsl-asserting-empty"></span><h3>asserting_empty<a class="headerlink" href="#asserting-empty" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_empty</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is present in input with empty value,</span>
<span class="k">else</span> <span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-empty-map">
<span id="reference-dsl-asserting-empty-map"></span><h3>asserting_empty_map<a class="headerlink" href="#asserting-empty-map" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_empty_map</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is a map with empty value, else</span>
<span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-float">
<span id="reference-dsl-asserting-float"></span><h3>asserting_float<a class="headerlink" href="#asserting-float" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_float</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is present with float value, else</span>
<span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-int">
<span id="reference-dsl-asserting-int"></span><h3>asserting_int<a class="headerlink" href="#asserting-int" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_int</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is present with int value, else</span>
<span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-map">
<span id="reference-dsl-asserting-map"></span><h3>asserting_map<a class="headerlink" href="#asserting-map" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_map</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is a map, else throws an error.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-nonempty-map">
<span id="reference-dsl-asserting-nonempty-map"></span><h3>asserting_nonempty_map<a class="headerlink" href="#asserting-nonempty-map" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_nonempty_map</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is a non-empty map, else throws</span>
<span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-not-empty">
<span id="reference-dsl-asserting-not-empty"></span><h3>asserting_not_empty<a class="headerlink" href="#asserting-not-empty" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_not_empty</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is present in input with non-empty</span>
<span class="n">value</span><span class="p">,</span> <span class="k">else</span> <span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-not-map">
<span id="reference-dsl-asserting-not-map"></span><h3>asserting_not_map<a class="headerlink" href="#asserting-not-map" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_not_map</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is not a map, else throws an error.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-not-null">
<span id="reference-dsl-asserting-not-null"></span><h3>asserting_not_null<a class="headerlink" href="#asserting-not-null" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_not_null</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is non-null (non-empty and non-absent),</span>
<span class="k">else</span> <span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-null">
<span id="reference-dsl-asserting-null"></span><h3>asserting_null<a class="headerlink" href="#asserting-null" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_null</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is null (empty or absent), else throws</span>
<span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-numeric">
<span id="reference-dsl-asserting-numeric"></span><h3>asserting_numeric<a class="headerlink" href="#asserting-numeric" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_numeric</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is present with int or float value,</span>
<span class="k">else</span> <span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-present">
<span id="reference-dsl-asserting-present"></span><h3>asserting_present<a class="headerlink" href="#asserting-present" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_present</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is present in input, else throws</span>
<span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="asserting-string">
<span id="reference-dsl-asserting-string"></span><h3>asserting_string<a class="headerlink" href="#asserting-string" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">asserting_string</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): Returns argument if it is present with string (including</span>
<span class="n">empty</span><span class="o">-</span><span class="n">string</span><span class="p">)</span> <span class="n">value</span><span class="p">,</span> <span class="k">else</span> <span class="n">throws</span> <span class="n">an</span> <span class="n">error</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="atan">
<span id="reference-dsl-atan"></span><h3>atan<a class="headerlink" href="#atan" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">atan</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): One-argument arctangent.</span>
</pre></div>
</div>
</div>
<div class="section" id="atan2">
<span id="reference-dsl-atan2"></span><h3>atan2<a class="headerlink" href="#atan2" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">atan2</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=2): Two-argument arctangent.</span>
</pre></div>
</div>
</div>
<div class="section" id="atanh">
<span id="reference-dsl-atanh"></span><h3>atanh<a class="headerlink" href="#atanh" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">atanh</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Inverse hyperbolic tangent.</span>
</pre></div>
</div>
</div>
<div class="section" id="bitcount">
<span id="reference-dsl-bitcount"></span><h3>bitcount<a class="headerlink" href="#bitcount" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">bitcount</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">arithmetic</span> <span class="c1">#args=1): Count of 1-bits</span>
</pre></div>
</div>
</div>
<div class="section" id="boolean">
<span id="reference-dsl-boolean"></span><h3>boolean<a class="headerlink" href="#boolean" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">boolean</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">conversion</span> <span class="c1">#args=1): Convert int/float/bool/string to boolean.</span>
</pre></div>
</div>
</div>
<div class="section" id="capitalize">
<span id="reference-dsl-capitalize"></span><h3>capitalize<a class="headerlink" href="#capitalize" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">capitalize</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): Convert string&#39;s first character to uppercase.</span>
</pre></div>
</div>
</div>
<div class="section" id="cbrt">
<span id="reference-dsl-cbrt"></span><h3>cbrt<a class="headerlink" href="#cbrt" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cbrt</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Cube root.</span>
</pre></div>
</div>
</div>
<div class="section" id="ceil">
<span id="reference-dsl-ceil"></span><h3>ceil<a class="headerlink" href="#ceil" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceil</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Ceiling: nearest integer at or above.</span>
</pre></div>
</div>
</div>
<div class="section" id="clean-whitespace">
<span id="reference-dsl-clean-whitespace"></span><h3>clean_whitespace<a class="headerlink" href="#clean-whitespace" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">clean_whitespace</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): Same as collapse_whitespace and strip.</span>
</pre></div>
</div>
</div>
<div class="section" id="collapse-whitespace">
<span id="reference-dsl-collapse-whitespace"></span><h3>collapse_whitespace<a class="headerlink" href="#collapse-whitespace" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">collapse_whitespace</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): Strip repeated whitespace from string.</span>
</pre></div>
</div>
</div>
<div class="section" id="cos">
<span id="reference-dsl-cos"></span><h3>cos<a class="headerlink" href="#cos" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cos</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Trigonometric cosine.</span>
</pre></div>
</div>
</div>
<div class="section" id="cosh">
<span id="reference-dsl-cosh"></span><h3>cosh<a class="headerlink" href="#cosh" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cosh</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Hyperbolic cosine.</span>
</pre></div>
</div>
</div>
<div class="section" id="depth">
<span id="reference-dsl-depth"></span><h3>depth<a class="headerlink" href="#depth" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">depth</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=1): Prints maximum depth of hashmap: &#39;&#39;. Scalars have depth 0.</span>
</pre></div>
</div>
</div>
<div class="section" id="dhms2fsec">
<span id="reference-dsl-dhms2fsec"></span><h3>dhms2fsec<a class="headerlink" href="#dhms2fsec" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">dhms2fsec</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Recovers floating-point seconds as in</span>
<span class="n">dhms2fsec</span><span class="p">(</span><span class="s2">&quot;5d18h53m20.250000s&quot;</span><span class="p">)</span> <span class="o">=</span> <span class="mf">500000.250000</span>
</pre></div>
</div>
</div>
<div class="section" id="dhms2sec">
<span id="reference-dsl-dhms2sec"></span><h3>dhms2sec<a class="headerlink" href="#dhms2sec" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">dhms2sec</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Recovers integer seconds as in</span>
<span class="n">dhms2sec</span><span class="p">(</span><span class="s2">&quot;5d18h53m20s&quot;</span><span class="p">)</span> <span class="o">=</span> <span class="mi">500000</span>
</pre></div>
</div>
</div>
<div class="section" id="erf">
<span id="reference-dsl-erf"></span><h3>erf<a class="headerlink" href="#erf" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">erf</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Error function.</span>
</pre></div>
</div>
</div>
<div class="section" id="erfc">
<span id="reference-dsl-erfc"></span><h3>erfc<a class="headerlink" href="#erfc" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">erfc</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Complementary error function.</span>
</pre></div>
</div>
</div>
<div class="section" id="exp">
<span id="reference-dsl-exp"></span><h3>exp<a class="headerlink" href="#exp" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">exp</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Exponential function e**x.</span>
</pre></div>
</div>
</div>
<div class="section" id="expm1">
<span id="reference-dsl-expm1"></span><h3>expm1<a class="headerlink" href="#expm1" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">expm1</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): e**x - 1.</span>
</pre></div>
</div>
</div>
<div class="section" id="float">
<span id="reference-dsl-float"></span><h3>float<a class="headerlink" href="#float" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">float</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">conversion</span> <span class="c1">#args=1): Convert int/float/bool/string to float.</span>
</pre></div>
</div>
</div>
<div class="section" id="floor">
<span id="reference-dsl-floor"></span><h3>floor<a class="headerlink" href="#floor" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">floor</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Floor: nearest integer at or below.</span>
</pre></div>
</div>
</div>
<div class="section" id="fmtnum">
<span id="reference-dsl-fmtnum"></span><h3>fmtnum<a class="headerlink" href="#fmtnum" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fmtnum</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">conversion</span> <span class="c1">#args=2): Convert int/float/bool to string using</span>
<span class="n">printf</span><span class="o">-</span><span class="n">style</span> <span class="nb">format</span> <span class="n">string</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;$s = fmtnum($n, &quot;%06lld&quot;)&#39;</span><span class="o">.</span> <span class="n">WARNING</span><span class="p">:</span> <span class="n">Miller</span> <span class="n">numbers</span>
<span class="n">are</span> <span class="nb">all</span> <span class="n">long</span> <span class="n">long</span> <span class="ow">or</span> <span class="n">double</span><span class="o">.</span> <span class="n">If</span> <span class="n">you</span> <span class="n">use</span> <span class="n">formats</span> <span class="n">like</span> <span class="o">%</span><span class="n">d</span> <span class="ow">or</span> <span class="o">%</span><span class="n">f</span><span class="p">,</span> <span class="n">behavior</span> <span class="ow">is</span> <span class="n">undefined</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="fsec2dhms">
<span id="reference-dsl-fsec2dhms"></span><h3>fsec2dhms<a class="headerlink" href="#fsec2dhms" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fsec2dhms</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Formats floating-point seconds as in</span>
<span class="n">fsec2dhms</span><span class="p">(</span><span class="mf">500000.25</span><span class="p">)</span> <span class="o">=</span> <span class="s2">&quot;5d18h53m20.250000s&quot;</span>
</pre></div>
</div>
</div>
<div class="section" id="fsec2hms">
<span id="reference-dsl-fsec2hms"></span><h3>fsec2hms<a class="headerlink" href="#fsec2hms" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fsec2hms</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Formats floating-point seconds as in</span>
<span class="n">fsec2hms</span><span class="p">(</span><span class="mf">5000.25</span><span class="p">)</span> <span class="o">=</span> <span class="s2">&quot;01:23:20.250000&quot;</span>
</pre></div>
</div>
</div>
<div class="section" id="gmt2sec">
<span id="reference-dsl-gmt2sec"></span><h3>gmt2sec<a class="headerlink" href="#gmt2sec" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">gmt2sec</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Parses GMT timestamp as integer seconds since</span>
<span class="n">the</span> <span class="n">epoch</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="gsub">
<span id="reference-dsl-gsub"></span><h3>gsub<a class="headerlink" href="#gsub" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">gsub</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=3): Example: &#39;$name=gsub($name, &quot;old&quot;, &quot;new&quot;)&#39;</span>
<span class="p">(</span><span class="n">replace</span> <span class="nb">all</span><span class="p">)</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="haskey">
<span id="reference-dsl-haskey"></span><h3>haskey<a class="headerlink" href="#haskey" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">haskey</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=2): True/false if map has/hasn&#39;t key, e.g. &#39;haskey($*, &quot;a&quot;)&#39; or</span>
<span class="s1">&#39;haskey(mymap, mykey)&#39;</span><span class="o">.</span> <span class="n">Error</span> <span class="k">if</span> <span class="mi">1</span><span class="n">st</span> <span class="n">argument</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">a</span> <span class="nb">map</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="hexfmt">
<span id="reference-dsl-hexfmt"></span><h3>hexfmt<a class="headerlink" href="#hexfmt" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">hexfmt</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">conversion</span> <span class="c1">#args=1): Convert int to string, e.g. 255 to &quot;0xff&quot;.</span>
</pre></div>
</div>
</div>
<div class="section" id="hms2fsec">
<span id="reference-dsl-hms2fsec"></span><h3>hms2fsec<a class="headerlink" href="#hms2fsec" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">hms2fsec</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Recovers floating-point seconds as in</span>
<span class="n">hms2fsec</span><span class="p">(</span><span class="s2">&quot;01:23:20.250000&quot;</span><span class="p">)</span> <span class="o">=</span> <span class="mf">5000.250000</span>
</pre></div>
</div>
</div>
<div class="section" id="hms2sec">
<span id="reference-dsl-hms2sec"></span><h3>hms2sec<a class="headerlink" href="#hms2sec" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">hms2sec</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Recovers integer seconds as in</span>
<span class="n">hms2sec</span><span class="p">(</span><span class="s2">&quot;01:23:20&quot;</span><span class="p">)</span> <span class="o">=</span> <span class="mi">5000</span>
</pre></div>
</div>
</div>
<div class="section" id="int">
<span id="reference-dsl-int"></span><h3>int<a class="headerlink" href="#int" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">int</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">conversion</span> <span class="c1">#args=1): Convert int/float/bool/string to int.</span>
</pre></div>
</div>
</div>
<div class="section" id="invqnorm">
<span id="reference-dsl-invqnorm"></span><h3>invqnorm<a class="headerlink" href="#invqnorm" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">invqnorm</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Inverse of normal cumulative distribution</span>
<span class="n">function</span><span class="o">.</span> <span class="n">Note</span> <span class="n">that</span> <span class="n">invqorm</span><span class="p">(</span><span class="n">urand</span><span class="p">())</span> <span class="ow">is</span> <span class="n">normally</span> <span class="n">distributed</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-absent">
<span id="reference-dsl-is-absent"></span><h3>is_absent<a class="headerlink" href="#is-absent" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_absent</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): False if field is present in input, true otherwise</span>
</pre></div>
</div>
</div>
<div class="section" id="is-bool">
<span id="reference-dsl-is-bool"></span><h3>is_bool<a class="headerlink" href="#is-bool" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_bool</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if field is present with boolean value. Synonymous with is_boolean.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-boolean">
<span id="reference-dsl-is-boolean"></span><h3>is_boolean<a class="headerlink" href="#is-boolean" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_boolean</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if field is present with boolean value. Synonymous with is_bool.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-empty">
<span id="reference-dsl-is-empty"></span><h3>is_empty<a class="headerlink" href="#is-empty" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_empty</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if field is present in input with empty string value, false otherwise.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-empty-map">
<span id="reference-dsl-is-empty-map"></span><h3>is_empty_map<a class="headerlink" href="#is-empty-map" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_empty_map</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if argument is a map which is empty.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-float">
<span id="reference-dsl-is-float"></span><h3>is_float<a class="headerlink" href="#is-float" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_float</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if field is present with value inferred to be float</span>
</pre></div>
</div>
</div>
<div class="section" id="is-int">
<span id="reference-dsl-is-int"></span><h3>is_int<a class="headerlink" href="#is-int" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_int</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if field is present with value inferred to be int</span>
</pre></div>
</div>
</div>
<div class="section" id="is-map">
<span id="reference-dsl-is-map"></span><h3>is_map<a class="headerlink" href="#is-map" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_map</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if argument is a map.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-nonempty-map">
<span id="reference-dsl-is-nonempty-map"></span><h3>is_nonempty_map<a class="headerlink" href="#is-nonempty-map" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_nonempty_map</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if argument is a map which is non-empty.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-not-empty">
<span id="reference-dsl-is-not-empty"></span><h3>is_not_empty<a class="headerlink" href="#is-not-empty" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_not_empty</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): False if field is present in input with empty value, true otherwise</span>
</pre></div>
</div>
</div>
<div class="section" id="is-not-map">
<span id="reference-dsl-is-not-map"></span><h3>is_not_map<a class="headerlink" href="#is-not-map" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_not_map</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if argument is not a map.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-not-null">
<span id="reference-dsl-is-not-null"></span><h3>is_not_null<a class="headerlink" href="#is-not-null" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_not_null</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): False if argument is null (empty or absent), true otherwise.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-null">
<span id="reference-dsl-is-null"></span><h3>is_null<a class="headerlink" href="#is-null" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_null</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if argument is null (empty or absent), false otherwise.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-numeric">
<span id="reference-dsl-is-numeric"></span><h3>is_numeric<a class="headerlink" href="#is-numeric" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_numeric</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if field is present with value inferred to be int or float</span>
</pre></div>
</div>
</div>
<div class="section" id="is-present">
<span id="reference-dsl-is-present"></span><h3>is_present<a class="headerlink" href="#is-present" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_present</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if field is present in input, false otherwise.</span>
</pre></div>
</div>
</div>
<div class="section" id="is-string">
<span id="reference-dsl-is-string"></span><h3>is_string<a class="headerlink" href="#is-string" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">is_string</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">typing</span> <span class="c1">#args=1): True if field is present with string (including empty-string) value</span>
</pre></div>
</div>
</div>
<div class="section" id="joink">
<span id="reference-dsl-joink"></span><h3>joink<a class="headerlink" href="#joink" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joink</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=2): Makes string from map keys. E.g. &#39;joink($*, &quot;,&quot;)&#39;.</span>
</pre></div>
</div>
</div>
<div class="section" id="joinkv">
<span id="reference-dsl-joinkv"></span><h3>joinkv<a class="headerlink" href="#joinkv" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joinkv</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=3): Makes string from map key-value pairs. E.g. &#39;joinkv(@v[2], &quot;=&quot;, &quot;,&quot;)&#39;</span>
</pre></div>
</div>
</div>
<div class="section" id="joinv">
<span id="reference-dsl-joinv"></span><h3>joinv<a class="headerlink" href="#joinv" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joinv</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=2): Makes string from map values. E.g. &#39;joinv(mymap, &quot;,&quot;)&#39;.</span>
</pre></div>
</div>
</div>
<div class="section" id="leafcount">
<span id="reference-dsl-leafcount"></span><h3>leafcount<a class="headerlink" href="#leafcount" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">leafcount</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=1): Counts total number of terminal values in hashmap. For single-level maps,</span>
<span class="n">same</span> <span class="k">as</span> <span class="n">length</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="length">
<span id="reference-dsl-length"></span><h3>length<a class="headerlink" href="#length" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">length</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=1): Counts number of top-level entries in hashmap. Scalars have length 1.</span>
</pre></div>
</div>
</div>
<div class="section" id="localtime2sec">
<span id="reference-dsl-localtime2sec"></span><h3>localtime2sec<a class="headerlink" href="#localtime2sec" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>localtime2sec (class=time #args=1): Parses local timestamp as integer seconds since
the epoch. Consults $TZ environment variable.
</pre></div>
</div>
</div>
<div class="section" id="log">
<span id="reference-dsl-log"></span><h3>log<a class="headerlink" href="#log" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">log</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Natural (base-e) logarithm.</span>
</pre></div>
</div>
</div>
<div class="section" id="log10">
<span id="reference-dsl-log10"></span><h3>log10<a class="headerlink" href="#log10" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">log10</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Base-10 logarithm.</span>
</pre></div>
</div>
</div>
<div class="section" id="log1p">
<span id="reference-dsl-log1p"></span><h3>log1p<a class="headerlink" href="#log1p" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">log1p</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): log(1-x).</span>
</pre></div>
</div>
</div>
<div class="section" id="logifit">
<span id="reference-dsl-logifit"></span><h3>logifit<a class="headerlink" href="#logifit" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>logifit (class=math #args=3): Given m and b from logistic regression, compute
fit: $yhat=logifit($x,$m,$b).
</pre></div>
</div>
</div>
<div class="section" id="lstrip">
<span id="reference-dsl-lstrip"></span><h3>lstrip<a class="headerlink" href="#lstrip" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">lstrip</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): Strip leading whitespace from string.</span>
</pre></div>
</div>
</div>
<div class="section" id="madd">
<span id="reference-dsl-madd"></span><h3>madd<a class="headerlink" href="#madd" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">madd</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=3): a + b mod m (integers)</span>
</pre></div>
</div>
</div>
<div class="section" id="mapdiff">
<span id="reference-dsl-mapdiff"></span><h3>mapdiff<a class="headerlink" href="#mapdiff" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mapdiff</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="n">variadic</span><span class="p">):</span> <span class="n">With</span> <span class="mi">0</span> <span class="n">args</span><span class="p">,</span> <span class="n">returns</span> <span class="n">empty</span> <span class="nb">map</span><span class="o">.</span> <span class="n">With</span> <span class="mi">1</span> <span class="n">arg</span><span class="p">,</span> <span class="n">returns</span> <span class="n">copy</span> <span class="n">of</span> <span class="n">arg</span><span class="o">.</span>
<span class="n">With</span> <span class="mi">2</span> <span class="ow">or</span> <span class="n">more</span><span class="p">,</span> <span class="n">returns</span> <span class="n">copy</span> <span class="n">of</span> <span class="n">arg</span> <span class="mi">1</span> <span class="k">with</span> <span class="nb">all</span> <span class="n">keys</span> <span class="kn">from</span> <span class="nn">any</span> <span class="n">of</span> <span class="n">remaining</span> <span class="n">argument</span> <span class="n">maps</span> <span class="n">removed</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="mapexcept">
<span id="reference-dsl-mapexcept"></span><h3>mapexcept<a class="headerlink" href="#mapexcept" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mapexcept</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="n">variadic</span><span class="p">):</span> <span class="n">Returns</span> <span class="n">a</span> <span class="nb">map</span> <span class="k">with</span> <span class="n">keys</span> <span class="kn">from</span> <span class="nn">remaining</span> <span class="n">arguments</span><span class="p">,</span> <span class="k">if</span> <span class="nb">any</span><span class="p">,</span> <span class="n">unset</span><span class="o">.</span>
<span class="n">E</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;mapexcept({1:2,3:4,5:6}, 1, 5, 7)&#39;</span> <span class="ow">is</span> <span class="s1">&#39;</span><span class="si">{3:4}</span><span class="s1">&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="mapselect">
<span id="reference-dsl-mapselect"></span><h3>mapselect<a class="headerlink" href="#mapselect" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mapselect</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="n">variadic</span><span class="p">):</span> <span class="n">Returns</span> <span class="n">a</span> <span class="nb">map</span> <span class="k">with</span> <span class="n">only</span> <span class="n">keys</span> <span class="kn">from</span> <span class="nn">remaining</span> <span class="n">arguments</span> <span class="nb">set</span><span class="o">.</span>
<span class="n">E</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;mapselect({1:2,3:4,5:6}, 1, 5, 7)&#39;</span> <span class="ow">is</span> <span class="s1">&#39;{1:2,5:6}&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="mapsum">
<span id="reference-dsl-mapsum"></span><h3>mapsum<a class="headerlink" href="#mapsum" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mapsum</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="n">variadic</span><span class="p">):</span> <span class="n">With</span> <span class="mi">0</span> <span class="n">args</span><span class="p">,</span> <span class="n">returns</span> <span class="n">empty</span> <span class="nb">map</span><span class="o">.</span> <span class="n">With</span> <span class="o">&gt;=</span> <span class="mi">1</span> <span class="n">arg</span><span class="p">,</span> <span class="n">returns</span> <span class="n">a</span> <span class="nb">map</span> <span class="k">with</span>
<span class="n">key</span><span class="o">-</span><span class="n">value</span> <span class="n">pairs</span> <span class="kn">from</span> <span class="nn">all</span> <span class="n">arguments</span><span class="o">.</span> <span class="n">Rightmost</span> <span class="n">collisions</span> <span class="n">win</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;mapsum({1:2,3:4},</span><span class="si">{1:5}</span><span class="s1">)&#39;</span> <span class="ow">is</span> <span class="s1">&#39;{1:5,3:4}&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="max">
<span id="reference-dsl-max"></span><h3>max<a class="headerlink" href="#max" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">max</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="n">variadic</span><span class="p">):</span> <span class="nb">max</span> <span class="n">of</span> <span class="n">n</span> <span class="n">numbers</span><span class="p">;</span> <span class="n">null</span> <span class="n">loses</span>
</pre></div>
</div>
</div>
<div class="section" id="mexp">
<span id="reference-dsl-mexp"></span><h3>mexp<a class="headerlink" href="#mexp" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mexp</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=3): a ** b mod m (integers)</span>
</pre></div>
</div>
</div>
<div class="section" id="min">
<span id="reference-dsl-min"></span><h3>min<a class="headerlink" href="#min" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">min</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="n">variadic</span><span class="p">):</span> <span class="n">Min</span> <span class="n">of</span> <span class="n">n</span> <span class="n">numbers</span><span class="p">;</span> <span class="n">null</span> <span class="n">loses</span>
</pre></div>
</div>
</div>
<div class="section" id="mmul">
<span id="reference-dsl-mmul"></span><h3>mmul<a class="headerlink" href="#mmul" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mmul</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=3): a * b mod m (integers)</span>
</pre></div>
</div>
</div>
<div class="section" id="msub">
<span id="reference-dsl-msub"></span><h3>msub<a class="headerlink" href="#msub" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">msub</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=3): a - b mod m (integers)</span>
</pre></div>
</div>
</div>
<div class="section" id="pow">
<span id="reference-dsl-pow"></span><h3>pow<a class="headerlink" href="#pow" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">pow</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=2): Exponentiation; same as **.</span>
</pre></div>
</div>
</div>
<div class="section" id="qnorm">
<span id="reference-dsl-qnorm"></span><h3>qnorm<a class="headerlink" href="#qnorm" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">qnorm</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Normal cumulative distribution function.</span>
</pre></div>
</div>
</div>
<div class="section" id="regextract">
<span id="reference-dsl-regextract"></span><h3>regextract<a class="headerlink" href="#regextract" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">regextract</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=2): Example: &#39;$name=regextract($name, &quot;[A-Z]{3}[0-9]{2}&quot;)&#39;</span>
<span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="regextract-or-else">
<span id="reference-dsl-regextract-or-else"></span><h3>regextract_or_else<a class="headerlink" href="#regextract-or-else" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">regextract_or_else</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=3): Example: &#39;$name=regextract_or_else($name, &quot;[A-Z]{3}[0-9]{2}&quot;, &quot;default&quot;)&#39;</span>
<span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="round">
<span id="reference-dsl-round"></span><h3>round<a class="headerlink" href="#round" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">round</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Round to nearest integer.</span>
</pre></div>
</div>
</div>
<div class="section" id="roundm">
<span id="reference-dsl-roundm"></span><h3>roundm<a class="headerlink" href="#roundm" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>roundm (class=math #args=2): Round to nearest multiple of m: roundm($x,$m) is
the same as round($x/$m)*$m
</pre></div>
</div>
</div>
<div class="section" id="rstrip">
<span id="reference-dsl-rstrip"></span><h3>rstrip<a class="headerlink" href="#rstrip" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rstrip</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): Strip trailing whitespace from string.</span>
</pre></div>
</div>
</div>
<div class="section" id="sec2dhms">
<span id="reference-dsl-sec2dhms"></span><h3>sec2dhms<a class="headerlink" href="#sec2dhms" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sec2dhms</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Formats integer seconds as in sec2dhms(500000)</span>
<span class="o">=</span> <span class="s2">&quot;5d18h53m20s&quot;</span>
</pre></div>
</div>
</div>
<div class="section" id="sec2gmt">
<span id="reference-dsl-sec2gmt"></span><h3>sec2gmt<a class="headerlink" href="#sec2gmt" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sec2gmt</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Formats seconds since epoch (integer part)</span>
<span class="k">as</span> <span class="n">GMT</span> <span class="n">timestamp</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="n">sec2gmt</span><span class="p">(</span><span class="mf">1440768801.7</span><span class="p">)</span> <span class="o">=</span> <span class="s2">&quot;2015-08-28T13:33:21Z&quot;</span><span class="o">.</span>
<span class="n">Leaves</span> <span class="n">non</span><span class="o">-</span><span class="n">numbers</span> <span class="k">as</span><span class="o">-</span><span class="ow">is</span><span class="o">.</span>
<span class="n">sec2gmt</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=2): Formats seconds since epoch as GMT timestamp with n</span>
<span class="n">decimal</span> <span class="n">places</span> <span class="k">for</span> <span class="n">seconds</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="n">sec2gmt</span><span class="p">(</span><span class="mf">1440768801.7</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="o">=</span> <span class="s2">&quot;2015-08-28T13:33:21.7Z&quot;</span><span class="o">.</span>
<span class="n">Leaves</span> <span class="n">non</span><span class="o">-</span><span class="n">numbers</span> <span class="k">as</span><span class="o">-</span><span class="ow">is</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="sec2gmtdate">
<span id="reference-dsl-sec2gmtdate"></span><h3>sec2gmtdate<a class="headerlink" href="#sec2gmtdate" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sec2gmtdate</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Formats seconds since epoch (integer part)</span>
<span class="k">as</span> <span class="n">GMT</span> <span class="n">timestamp</span> <span class="k">with</span> <span class="n">year</span><span class="o">-</span><span class="n">month</span><span class="o">-</span><span class="n">date</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="n">sec2gmtdate</span><span class="p">(</span><span class="mf">1440768801.7</span><span class="p">)</span> <span class="o">=</span> <span class="s2">&quot;2015-08-28&quot;</span><span class="o">.</span>
<span class="n">Leaves</span> <span class="n">non</span><span class="o">-</span><span class="n">numbers</span> <span class="k">as</span><span class="o">-</span><span class="ow">is</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="sec2hms">
<span id="reference-dsl-sec2hms"></span><h3>sec2hms<a class="headerlink" href="#sec2hms" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sec2hms</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=1): Formats integer seconds as in</span>
<span class="n">sec2hms</span><span class="p">(</span><span class="mi">5000</span><span class="p">)</span> <span class="o">=</span> <span class="s2">&quot;01:23:20&quot;</span>
</pre></div>
</div>
</div>
<div class="section" id="sec2localdate">
<span id="reference-dsl-sec2localdate"></span><h3>sec2localdate<a class="headerlink" href="#sec2localdate" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>sec2localdate (class=time #args=1): Formats seconds since epoch (integer part)
as local timestamp with year-month-date, e.g. sec2localdate(1440768801.7) = &quot;2015-08-28&quot;.
Consults $TZ environment variable. Leaves non-numbers as-is.
</pre></div>
</div>
</div>
<div class="section" id="sec2localtime">
<span id="reference-dsl-sec2localtime"></span><h3>sec2localtime<a class="headerlink" href="#sec2localtime" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>sec2localtime (class=time #args=1): Formats seconds since epoch (integer part)
as local timestamp, e.g. sec2localtime(1440768801.7) = &quot;2015-08-28T13:33:21Z&quot;.
Consults $TZ environment variable. Leaves non-numbers as-is.
sec2localtime (class=time #args=2): Formats seconds since epoch as local timestamp with n
decimal places for seconds, e.g. sec2localtime(1440768801.7,1) = &quot;2015-08-28T13:33:21.7Z&quot;.
Consults $TZ environment variable. Leaves non-numbers as-is.
</pre></div>
</div>
</div>
<div class="section" id="sgn">
<span id="reference-dsl-sgn"></span><h3>sgn<a class="headerlink" href="#sgn" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sgn</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): +1 for positive input, 0 for zero input, -1 for</span>
<span class="n">negative</span> <span class="nb">input</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="sin">
<span id="reference-dsl-sin"></span><h3>sin<a class="headerlink" href="#sin" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sin</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Trigonometric sine.</span>
</pre></div>
</div>
</div>
<div class="section" id="sinh">
<span id="reference-dsl-sinh"></span><h3>sinh<a class="headerlink" href="#sinh" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sinh</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Hyperbolic sine.</span>
</pre></div>
</div>
</div>
<div class="section" id="splitkv">
<span id="reference-dsl-splitkv"></span><h3>splitkv<a class="headerlink" href="#splitkv" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">splitkv</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=3): Splits string by separators into map with type inference.</span>
<span class="n">E</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;splitkv(&quot;a=1,b=2,c=3&quot;, &quot;=&quot;, &quot;,&quot;)&#39;</span> <span class="n">gives</span> <span class="s1">&#39;{&quot;a&quot; : 1, &quot;b&quot; : 2, &quot;c&quot; : 3}&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="splitkvx">
<span id="reference-dsl-splitkvx"></span><h3>splitkvx<a class="headerlink" href="#splitkvx" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">splitkvx</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=3): Splits string by separators into map without type inference (keys and</span>
<span class="n">values</span> <span class="n">are</span> <span class="n">strings</span><span class="p">)</span><span class="o">.</span> <span class="n">E</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;splitkv(&quot;a=1,b=2,c=3&quot;, &quot;=&quot;, &quot;,&quot;)&#39;</span> <span class="n">gives</span>
<span class="s1">&#39;{&quot;a&quot; : &quot;1&quot;, &quot;b&quot; : &quot;2&quot;, &quot;c&quot; : &quot;3&quot;}&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="splitnv">
<span id="reference-dsl-splitnv"></span><h3>splitnv<a class="headerlink" href="#splitnv" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">splitnv</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=2): Splits string by separator into integer-indexed map with type inference.</span>
<span class="n">E</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;splitnv(&quot;a,b,c&quot; , &quot;,&quot;)&#39;</span> <span class="n">gives</span> <span class="s1">&#39;{1 : &quot;a&quot;, 2 : &quot;b&quot;, 3 : &quot;c&quot;}&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="splitnvx">
<span id="reference-dsl-splitnvx"></span><h3>splitnvx<a class="headerlink" href="#splitnvx" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">splitnvx</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">maps</span> <span class="c1">#args=2): Splits string by separator into integer-indexed map without type</span>
<span class="n">inference</span> <span class="p">(</span><span class="n">values</span> <span class="n">are</span> <span class="n">strings</span><span class="p">)</span><span class="o">.</span> <span class="n">E</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="s1">&#39;splitnv(&quot;4,5,6&quot; , &quot;,&quot;)&#39;</span> <span class="n">gives</span> <span class="s1">&#39;{1 : &quot;4&quot;, 2 : &quot;5&quot;, 3 : &quot;6&quot;}&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="sqrt">
<span id="reference-dsl-sqrt"></span><h3>sqrt<a class="headerlink" href="#sqrt" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sqrt</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Square root.</span>
</pre></div>
</div>
</div>
<div class="section" id="ssub">
<span id="reference-dsl-ssub"></span><h3>ssub<a class="headerlink" href="#ssub" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssub</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=3): Like sub but does no regexing. No characters are special.</span>
</pre></div>
</div>
</div>
<div class="section" id="strftime">
<span id="reference-dsl-strftime"></span><h3>strftime<a class="headerlink" href="#strftime" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">strftime</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=2): Formats seconds since the epoch as timestamp, e.g.</span>
<span class="n">strftime</span><span class="p">(</span><span class="mf">1440768801.7</span><span class="p">,</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2">T%H:%M:%SZ&quot;</span><span class="p">)</span> <span class="o">=</span> <span class="s2">&quot;2015-08-28T13:33:21Z&quot;</span><span class="p">,</span> <span class="ow">and</span>
<span class="n">strftime</span><span class="p">(</span><span class="mf">1440768801.7</span><span class="p">,</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2">T%H:%M:%3SZ&quot;</span><span class="p">)</span> <span class="o">=</span> <span class="s2">&quot;2015-08-28T13:33:21.700Z&quot;</span><span class="o">.</span>
<span class="n">Format</span> <span class="n">strings</span> <span class="n">are</span> <span class="k">as</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">C</span> <span class="n">library</span> <span class="p">(</span><span class="n">please</span> <span class="n">see</span> <span class="s2">&quot;man strftime&quot;</span> <span class="n">on</span> <span class="n">your</span> <span class="n">system</span><span class="p">),</span>
<span class="k">with</span> <span class="n">the</span> <span class="n">Miller</span><span class="o">-</span><span class="n">specific</span> <span class="n">addition</span> <span class="n">of</span> <span class="s2">&quot;%1S&quot;</span> <span class="n">through</span> <span class="s2">&quot;%9S&quot;</span> <span class="n">which</span> <span class="nb">format</span> <span class="n">the</span> <span class="n">seconds</span>
<span class="k">with</span> <span class="mi">1</span> <span class="n">through</span> <span class="mi">9</span> <span class="n">decimal</span> <span class="n">places</span><span class="p">,</span> <span class="n">respectively</span><span class="o">.</span> <span class="p">(</span><span class="s2">&quot;%S&quot;</span> <span class="n">uses</span> <span class="n">no</span> <span class="n">decimal</span> <span class="n">places</span><span class="o">.</span><span class="p">)</span>
<span class="n">See</span> <span class="n">also</span> <span class="n">strftime_local</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="strftime-local">
<span id="reference-dsl-strftime-local"></span><h3>strftime_local<a class="headerlink" href="#strftime-local" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">strftime_local</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=2): Like strftime but consults the $TZ environment variable to get local time zone.</span>
</pre></div>
</div>
</div>
<div class="section" id="string">
<span id="reference-dsl-string"></span><h3>string<a class="headerlink" href="#string" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">string</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">conversion</span> <span class="c1">#args=1): Convert int/float/bool/string to string.</span>
</pre></div>
</div>
</div>
<div class="section" id="strip">
<span id="reference-dsl-strip"></span><h3>strip<a class="headerlink" href="#strip" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">strip</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): Strip leading and trailing whitespace from string.</span>
</pre></div>
</div>
</div>
<div class="section" id="strlen">
<span id="reference-dsl-strlen"></span><h3>strlen<a class="headerlink" href="#strlen" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">strlen</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): String length.</span>
</pre></div>
</div>
</div>
<div class="section" id="strptime">
<span id="reference-dsl-strptime"></span><h3>strptime<a class="headerlink" href="#strptime" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">strptime</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=2): Parses timestamp as floating-point seconds since the epoch,</span>
<span class="n">e</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="n">strptime</span><span class="p">(</span><span class="s2">&quot;2015-08-28T13:33:21Z&quot;</span><span class="p">,</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2">T%H:%M:%SZ&quot;</span><span class="p">)</span> <span class="o">=</span> <span class="mf">1440768801.000000</span><span class="p">,</span>
<span class="ow">and</span> <span class="n">strptime</span><span class="p">(</span><span class="s2">&quot;2015-08-28T13:33:21.345Z&quot;</span><span class="p">,</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2">T%H:%M:%SZ&quot;</span><span class="p">)</span> <span class="o">=</span> <span class="mf">1440768801.345000</span><span class="o">.</span>
<span class="n">See</span> <span class="n">also</span> <span class="n">strptime_local</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="strptime-local">
<span id="reference-dsl-strptime-local"></span><h3>strptime_local<a class="headerlink" href="#strptime-local" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">strptime_local</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=2): Like strptime, but consults $TZ environment variable to find and use local timezone.</span>
</pre></div>
</div>
</div>
<div class="section" id="sub">
<span id="reference-dsl-sub"></span><h3>sub<a class="headerlink" href="#sub" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sub</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=3): Example: &#39;$name=sub($name, &quot;old&quot;, &quot;new&quot;)&#39;</span>
<span class="p">(</span><span class="n">replace</span> <span class="n">once</span><span class="p">)</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="substr">
<span id="reference-dsl-substr"></span><h3>substr<a class="headerlink" href="#substr" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">substr</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=3): substr(s,m,n) gives substring of s from 0-up position m to n</span>
<span class="n">inclusive</span><span class="o">.</span> <span class="n">Negative</span> <span class="n">indices</span> <span class="o">-</span><span class="nb">len</span> <span class="o">..</span> <span class="o">-</span><span class="mi">1</span> <span class="n">alias</span> <span class="n">to</span> <span class="mi">0</span> <span class="o">..</span> <span class="nb">len</span><span class="o">-</span><span class="mf">1.</span>
</pre></div>
</div>
</div>
<div class="section" id="system">
<span id="reference-dsl-system"></span><h3>system<a class="headerlink" href="#system" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">system</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): Run command string, yielding its stdout minus final carriage return.</span>
</pre></div>
</div>
</div>
<div class="section" id="systime">
<span id="reference-dsl-systime"></span><h3>systime<a class="headerlink" href="#systime" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">systime</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">time</span> <span class="c1">#args=0): Floating-point seconds since the epoch,</span>
<span class="n">e</span><span class="o">.</span><span class="n">g</span><span class="o">.</span> <span class="mf">1440768801.748936</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="tan">
<span id="reference-dsl-tan"></span><h3>tan<a class="headerlink" href="#tan" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">tan</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Trigonometric tangent.</span>
</pre></div>
</div>
</div>
<div class="section" id="tanh">
<span id="reference-dsl-tanh"></span><h3>tanh<a class="headerlink" href="#tanh" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">tanh</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=1): Hyperbolic tangent.</span>
</pre></div>
</div>
</div>
<div class="section" id="tolower">
<span id="reference-dsl-tolower"></span><h3>tolower<a class="headerlink" href="#tolower" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">tolower</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): Convert string to lowercase.</span>
</pre></div>
</div>
</div>
<div class="section" id="toupper">
<span id="reference-dsl-toupper"></span><h3>toupper<a class="headerlink" href="#toupper" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">toupper</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=1): Convert string to uppercase.</span>
</pre></div>
</div>
</div>
<div class="section" id="truncate">
<span id="reference-dsl-truncate"></span><h3>truncate<a class="headerlink" href="#truncate" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">truncate</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">string</span> <span class="c1">#args=2): Truncates string first argument to max length of int second argument.</span>
</pre></div>
</div>
</div>
<div class="section" id="typeof">
<span id="reference-dsl-typeof"></span><h3>typeof<a class="headerlink" href="#typeof" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">typeof</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">conversion</span> <span class="c1">#args=1): Convert argument to type of argument (e.g.</span>
<span class="n">MT_STRING</span><span class="p">)</span><span class="o">.</span> <span class="n">For</span> <span class="n">debug</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="urand">
<span id="reference-dsl-urand"></span><h3>urand<a class="headerlink" href="#urand" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">urand</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=0): Floating-point numbers uniformly distributed on the unit interval.</span>
<span class="n">Int</span><span class="o">-</span><span class="n">valued</span> <span class="n">example</span><span class="p">:</span> <span class="s1">&#39;$n=floor(20+urand()*11)&#39;</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="urand32">
<span id="reference-dsl-urand32"></span><h3>urand32<a class="headerlink" href="#urand32" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">urand32</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=0): Integer uniformly distributed 0 and 2**32-1</span>
<span class="n">inclusive</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="urandint">
<span id="reference-dsl-urandint"></span><h3>urandint<a class="headerlink" href="#urandint" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">urandint</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=2): Integer uniformly distributed between inclusive</span>
<span class="n">integer</span> <span class="n">endpoints</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="urandrange">
<span id="reference-dsl-urandrange"></span><h3>urandrange<a class="headerlink" href="#urandrange" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">urandrange</span> <span class="p">(</span><span class="n">class</span><span class="o">=</span><span class="n">math</span> <span class="c1">#args=2): Floating-point numbers uniformly distributed on the interval [a, b).</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="user-defined-functions-and-subroutines">
<h2>User-defined functions and subroutines<a class="headerlink" href="#user-defined-functions-and-subroutines" title="Permalink to this headline"></a></h2>
<p>As of Miller 5.0.0 you can define your own functions, as well as subroutines.</p>
<div class="section" id="user-defined-functions">
<h3>User-defined functions<a class="headerlink" href="#user-defined-functions" title="Permalink to this headline"></a></h3>
<p>Heres the obligatory example of a recursive function to compute the factorial function:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --opprint --from data/small put &#39;
func f(n) {
if (is_numeric(n)) {
if (n &gt; 0) {
return n * f(n-1);
} else {
return 1;
}
}
# implicitly return absent-null if non-numeric
}
$ox = f($x + NR);
$oi = f($i);
&#39;
a b i x y ox oi
pan pan 1 0.3467901443380824 0.7268028627434533 0.467054 1
eks pan 2 0.7586799647899636 0.5221511083334797 3.680838 2
wye wye 3 0.20460330576630303 0.33831852551664776 1.741251 6
eks wye 4 0.38139939387114097 0.13418874328430463 18.588349 24
wye pan 5 0.5732889198020006 0.8636244699032729 211.387310 120
</pre></div>
</div>
<p>Properties of user-defined functions:</p>
<ul class="simple">
<li><p>Function bodies start with <code class="docutils literal notranslate"><span class="pre">func</span></code> and a parameter list, defined outside of <code class="docutils literal notranslate"><span class="pre">begin</span></code>, <code class="docutils literal notranslate"><span class="pre">end</span></code>, or other <code class="docutils literal notranslate"><span class="pre">func</span></code> or <code class="docutils literal notranslate"><span class="pre">subr</span></code> blocks. (I.e. the Miller DSL has no nested functions.)</p></li>
<li><p>A function (uniqified by its name) may not be redefined: either by redefining a user-defined function, or by redefining a built-in function. However, functions and subroutines have separate namespaces: you can define a subroutine <code class="docutils literal notranslate"><span class="pre">log</span></code> which does not clash with the mathematical <code class="docutils literal notranslate"><span class="pre">log</span></code> function.</p></li>
<li><p>Functions may be defined either before or after use (there is an object-binding/linkage step at startup). More specifically, functions may be either recursive or mutually recursive. Functions may not call subroutines.</p></li>
<li><p>Functions may be defined and called either within <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code> or <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code>.</p></li>
<li><p>Functions have read access to <code class="docutils literal notranslate"><span class="pre">$</span></code>-variables and <code class="docutils literal notranslate"><span class="pre">&#64;</span></code>-variables but may not modify them. See also <a class="reference internal" href="cookbook.html#cookbook-memoization-with-oosvars"><span class="std std-ref">Memoization with out-of-stream variables</span></a> for an example.</p></li>
<li><p>Argument values may be reassigned: they are not read-only.</p></li>
<li><p>When a return value is not implicitly returned, this results in a return value of absent-null. (In the example above, if there were records for which the argument to <code class="docutils literal notranslate"><span class="pre">f</span></code> is non-numeric, the assignments would be skipped.) See also the section on <a class="reference internal" href="reference.html#reference-null-data"><span class="std std-ref">Null data: empty and absent</span></a>.</p></li>
<li><p>See the section on <a class="reference internal" href="#reference-dsl-local-variables"><span class="std std-ref">Local variables</span></a> for information on scope and extent of arguments, as well as for information on the use of local variables within functions.</p></li>
<li><p>See the section on <a class="reference internal" href="#reference-dsl-expressions-from-files"><span class="std std-ref">Expressions from files</span></a> for information on the use of <code class="docutils literal notranslate"><span class="pre">-f</span></code> and <code class="docutils literal notranslate"><span class="pre">-e</span></code> flags.</p></li>
</ul>
</div>
<div class="section" id="user-defined-subroutines">
<h3>User-defined subroutines<a class="headerlink" href="#user-defined-subroutines" title="Permalink to this headline"></a></h3>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mlr --opprint --from data/small put -q &#39;
begin {
@call_count = 0;
}
subr s(n) {
@call_count += 1;
if (is_numeric(n)) {
if (n &gt; 1) {
call s(n-1);
} else {
print &quot;numcalls=&quot; . @call_count;
}
}
}
print &quot;NR=&quot; . NR;
call s(NR);
&#39;
NR=1
numcalls=1
NR=2
numcalls=3
NR=3
numcalls=6
NR=4
numcalls=10
NR=5
numcalls=15
</pre></div>
</div>
<p>Properties of user-defined subroutines:</p>
<ul class="simple">
<li><p>Subroutine bodies start with <code class="docutils literal notranslate"><span class="pre">subr</span></code> and a parameter list, defined outside of <code class="docutils literal notranslate"><span class="pre">begin</span></code>, <code class="docutils literal notranslate"><span class="pre">end</span></code>, or other <code class="docutils literal notranslate"><span class="pre">func</span></code> or <code class="docutils literal notranslate"><span class="pre">subr</span></code> blocks. (I.e. the Miller DSL has no nested subroutines.)</p></li>
<li><p>A subroutine (uniqified by its name) may not be redefined. However, functions and subroutines have separate namespaces: you can define a subroutine <code class="docutils literal notranslate"><span class="pre">log</span></code> which does not clash with the mathematical <code class="docutils literal notranslate"><span class="pre">log</span></code> function.</p></li>
<li><p>Subroutines may be defined either before or after use (there is an object-binding/linkage step at startup). More specifically, subroutines may be either recursive or mutually recursive. Subroutines may call functions.</p></li>
<li><p>Subroutines may be defined and called either within <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code> or <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code>.</p></li>
<li><p>Subroutines have read/write access to <code class="docutils literal notranslate"><span class="pre">$</span></code>-variables and <code class="docutils literal notranslate"><span class="pre">&#64;</span></code>-variables.</p></li>
<li><p>Argument values may be reassigned: they are not read-only.</p></li>
<li><p>See the section on <a class="reference internal" href="#reference-dsl-local-variables"><span class="std std-ref">Local variables</span></a> for information on scope and extent of arguments, as well as for information on the use of local variables within functions.</p></li>
<li><p>See the section on <a class="reference internal" href="#reference-dsl-expressions-from-files"><span class="std std-ref">Expressions from files</span></a> for information on the use of <code class="docutils literal notranslate"><span class="pre">-f</span></code> and <code class="docutils literal notranslate"><span class="pre">-e</span></code> flags.</p></li>
</ul>
</div>
</div>
<div class="section" id="errors-and-transparency">
<span id="reference-dsl-errors-and-transparency"></span><h2>Errors and transparency<a class="headerlink" href="#errors-and-transparency" title="Permalink to this headline"></a></h2>
<p>As soon as you have a programming language, you start having the problem <em>What is my code doing, and why?</em> This includes getting syntax errors which are always annoying as well as the even more annoying problem of a program which parses without syntax error but doesnt do what you expect.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">syntax</span> <span class="pre">error</span></code> message is cryptic: it says <code class="docutils literal notranslate"><span class="pre">syntax</span> <span class="pre">error</span> <span class="pre">at</span> <span class="pre">``</span> <span class="pre">followed</span> <span class="pre">by</span> <span class="pre">the</span> <span class="pre">next</span> <span class="pre">symbol</span> <span class="pre">it</span> <span class="pre">couldn't</span> <span class="pre">parse.</span> <span class="pre">This</span> <span class="pre">is</span> <span class="pre">good,</span> <span class="pre">but</span> <span class="pre">(as</span> <span class="pre">of</span> <span class="pre">5.0.0)</span> <span class="pre">it</span> <span class="pre">doesn't</span> <span class="pre">say</span> <span class="pre">things</span> <span class="pre">like</span> <span class="pre">``syntax</span> <span class="pre">error</span> <span class="pre">at</span> <span class="pre">line</span> <span class="pre">17,</span> <span class="pre">character</span> <span class="pre">22</span></code>. Here are some common causes of syntax errors:</p>
<ul class="simple">
<li><p>Dont forget <code class="docutils literal notranslate"><span class="pre">;</span></code> at end of line, before another statement on the next line.</p></li>
<li><p>Millers DSL lacks the <code class="docutils literal notranslate"><span class="pre">++</span></code> and <code class="docutils literal notranslate"><span class="pre">--</span></code> operators.</p></li>
<li><p>Curly braces are required for the bodies of <code class="docutils literal notranslate"><span class="pre">if</span></code>/<code class="docutils literal notranslate"><span class="pre">while</span></code>/<code class="docutils literal notranslate"><span class="pre">for</span></code> blocks, even when the body is a single statement.</p></li>
</ul>
<p>Now for transparency:</p>
<ul class="simple">
<li><p>As in any language, you can do (see <a class="reference internal" href="#reference-dsl-print-statements"><span class="std std-ref">Print statements</span></a>) <code class="docutils literal notranslate"><span class="pre">print</span></code> (or <code class="docutils literal notranslate"><span class="pre">eprint</span></code> to print to stderr). See also <a class="reference internal" href="#reference-dsl-dump-statements"><span class="std std-ref">Dump statements</span></a> and <a class="reference internal" href="#reference-dsl-emit-statements"><span class="std std-ref">Emit statements</span></a>.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">-v</span></code> option to <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span></code> and <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">filter</span></code> prints abstract syntax trees for your code. While not all details here will be of interest to everyone, certainly this makes questions such as operator precedence completely unambiguous.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">-T</span></code> option prints a trace of each statement executed.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">-t</span></code> and <code class="docutils literal notranslate"><span class="pre">-a</span></code> options show low-level details for the parsing process and for stack-variable-index allocation, respectively. These will likely be of interest to people who enjoy compilers, and probably less useful for a more general audience.</p></li>
<li><p>Please see <a class="reference internal" href="#reference-dsl-type-checking"><span class="std std-ref">Type-checking</span></a> for type declarations and type-assertions you can use to make sure expressions and the data flowing them are evaluating as you expect. I made them optional because one of Millers important use-cases is being able to say simple things like <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">put</span> <span class="pre">'$y</span> <span class="pre">=</span> <span class="pre">$x</span> <span class="pre">+</span> <span class="pre">1'</span> <span class="pre">myfile.dat</span></code> with a minimum of punctuational bric-a-brac but for programs over a few lines I generally find that the more type-specification, the better.</p></li>
</ul>
</div>
<div class="section" id="a-note-on-the-complexity-of-miller-s-expression-language">
<h2>A note on the complexity of Millers expression language<a class="headerlink" href="#a-note-on-the-complexity-of-miller-s-expression-language" title="Permalink to this headline"></a></h2>
<p>One of Millers strengths is its brevity: its much quicker and less error-prone to type <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">stats1</span> <span class="pre">-a</span> <span class="pre">sum</span> <span class="pre">-f</span> <span class="pre">x,y</span> <span class="pre">-g</span> <span class="pre">a,b</span></code> than having to track summation variables as in <code class="docutils literal notranslate"><span class="pre">awk</span></code>, or using Millers out-of-stream variables. And the more language features Millers put-DSL has (for-loops, if-statements, nested control structures, user-defined functions, etc.) then the <em>less</em> powerful it begins to seem: because of the other programming-language features it <em>doesnt</em> have (classes, execptions, and so on).</p>
<p>When I was originally prototyping Miller in 2015, the decision I had was whether to hand-code in a low-level language like C or Rust, with my own hand-rolled DSL, or whether to use a higher-level language (like Python or Lua or Nim) and let the <code class="docutils literal notranslate"><span class="pre">put</span></code> statements be handled by the implementation languages own <code class="docutils literal notranslate"><span class="pre">eval</span></code>: the implementation language would take the place of a DSL. Multiple performance experiments showed me I could get better throughput using the former, and using C in particular by a wide margin. So Miller is C under the hood with a hand-rolled DSL.</p>
<p>I do want to keep focusing on what Miller is good at concise notation, low latency, and high throughput and not add too much in terms of high-level-language features to the DSL. That said, some sort of customizability is a basic thing to want. As of 4.1.0 we have recursive for/while/if structures on about the same complexity level as <code class="docutils literal notranslate"><span class="pre">awk</span></code>; as of 5.0.0 we have user-defined functions and map-valued variables, again on about the same complexity level as <code class="docutils literal notranslate"><span class="pre">awk</span></code> along with optional type-declaration syntax. While Im excited by these powerful language features, I hope to keep new features beyond 5.0.0 focused on Millers sweet spot which is speed plus simplicity.</p>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">DSL reference</a><ul>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#syntax">Syntax</a><ul>
<li><a class="reference internal" href="#expression-formatting">Expression formatting</a></li>
<li><a class="reference internal" href="#expressions-from-files">Expressions from files</a></li>
<li><a class="reference internal" href="#semicolons-commas-newlines-and-curly-braces">Semicolons, commas, newlines, and curly braces</a></li>
</ul>
</li>
<li><a class="reference internal" href="#variables">Variables</a><ul>
<li><a class="reference internal" href="#built-in-variables">Built-in variables</a></li>
<li><a class="reference internal" href="#field-names">Field names</a></li>
<li><a class="reference internal" href="#positional-field-names">Positional field names</a></li>
<li><a class="reference internal" href="#out-of-stream-variables">Out-of-stream variables</a></li>
<li><a class="reference internal" href="#indexed-out-of-stream-variables">Indexed out-of-stream variables</a></li>
<li><a class="reference internal" href="#local-variables">Local variables</a></li>
<li><a class="reference internal" href="#map-literals">Map literals</a></li>
<li><a class="reference internal" href="#type-checking">Type-checking</a><ul>
<li><a class="reference internal" href="#type-test-and-type-assertion-expressions">Type-test and type-assertion expressions</a></li>
<li><a class="reference internal" href="#type-declarations-for-local-variables-function-parameter-and-function-return-values">Type-declarations for local variables, function parameter, and function return values</a></li>
</ul>
</li>
<li><a class="reference internal" href="#null-data-empty-and-absent">Null data: empty and absent</a></li>
<li><a class="reference internal" href="#aggregate-variable-assignments">Aggregate variable assignments</a></li>
<li><a class="reference internal" href="#keywords-for-filter-and-put">Keywords for filter and put</a></li>
</ul>
</li>
<li><a class="reference internal" href="#operator-precedence">Operator precedence</a></li>
<li><a class="reference internal" href="#operator-and-function-semantics">Operator and function semantics</a></li>
<li><a class="reference internal" href="#control-structures">Control structures</a><ul>
<li><a class="reference internal" href="#pattern-action-blocks">Pattern-action blocks</a></li>
<li><a class="reference internal" href="#if-statements">If-statements</a></li>
<li><a class="reference internal" href="#while-and-do-while-loops">While and do-while loops</a></li>
<li><a class="reference internal" href="#for-loops">For-loops</a><ul>
<li><a class="reference internal" href="#key-only-for-loops">Key-only for-loops</a></li>
<li><a class="reference internal" href="#key-value-for-loops">Key-value for-loops</a></li>
<li><a class="reference internal" href="#c-style-triple-for-loops">C-style triple-for loops</a></li>
</ul>
</li>
<li><a class="reference internal" href="#begin-end-blocks">Begin/end blocks</a></li>
</ul>
</li>
<li><a class="reference internal" href="#output-statements">Output statements</a><ul>
<li><a class="reference internal" href="#print-statements">Print statements</a></li>
<li><a class="reference internal" href="#dump-statements">Dump statements</a></li>
<li><a class="reference internal" href="#tee-statements">Tee statements</a></li>
<li><a class="reference internal" href="#redirected-output-statements">Redirected-output statements</a></li>
<li><a class="reference internal" href="#emit-statements">Emit statements</a></li>
<li><a class="reference internal" href="#multi-emit-statements">Multi-emit statements</a></li>
<li><a class="reference internal" href="#emit-all-statements">Emit-all statements</a></li>
</ul>
</li>
<li><a class="reference internal" href="#unset-statements">Unset statements</a></li>
<li><a class="reference internal" href="#filter-statements">Filter statements</a></li>
<li><a class="reference internal" href="#built-in-functions-for-filter-and-put-summary">Built-in functions for filter and put, summary</a></li>
<li><a class="reference internal" href="#built-in-functions-for-filter-and-put">Built-in functions for filter and put</a><ul>
<li><a class="reference internal" href="#reference-dsl-plus">+</a></li>
<li><a class="reference internal" href="#reference-dsl-minus">-</a></li>
<li><a class="reference internal" href="#reference-dsl-times">*</a></li>
<li><a class="reference internal" href="#id4">/</a></li>
<li><a class="reference internal" href="#id6">//</a></li>
<li><a class="reference internal" href="#id7">.+</a></li>
<li><a class="reference internal" href="#id9">.-</a></li>
<li><a class="reference internal" href="#id11">.*</a></li>
<li><a class="reference internal" href="#id13">./</a></li>
<li><a class="reference internal" href="#id15">.//</a></li>
<li><a class="reference internal" href="#id18">%</a></li>
<li><a class="reference internal" href="#reference-dsl-exponentiation">**</a></li>
<li><a class="reference internal" href="#reference-dsl-bitwise-or">|</a></li>
<li><a class="reference internal" href="#id22">^</a></li>
<li><a class="reference internal" href="#id24">&amp;</a></li>
<li><a class="reference internal" href="#id26">~</a></li>
<li><a class="reference internal" href="#id28">&lt;&lt;</a></li>
<li><a class="reference internal" href="#id30">&gt;&gt;</a></li>
<li><a class="reference internal" href="#id32">==</a></li>
<li><a class="reference internal" href="#id33">!=</a></li>
<li><a class="reference internal" href="#id35">=~</a></li>
<li><a class="reference internal" href="#id37">!=~</a></li>
<li><a class="reference internal" href="#id40">&gt;</a></li>
<li><a class="reference internal" href="#id41">&gt;=</a></li>
<li><a class="reference internal" href="#id44">&lt;</a></li>
<li><a class="reference internal" href="#id45">&lt;=</a></li>
<li><a class="reference internal" href="#id48">&amp;&amp;</a></li>
<li><a class="reference internal" href="#id50">||</a></li>
<li><a class="reference internal" href="#id52">^^</a></li>
<li><a class="reference internal" href="#id54">!</a></li>
<li><a class="reference internal" href="#reference-dsl-question-mark-colon">?</a></li>
<li><a class="reference internal" href="#id57">.</a></li>
<li><a class="reference internal" href="#abs">abs</a></li>
<li><a class="reference internal" href="#acos">acos</a></li>
<li><a class="reference internal" href="#acosh">acosh</a></li>
<li><a class="reference internal" href="#asin">asin</a></li>
<li><a class="reference internal" href="#asinh">asinh</a></li>
<li><a class="reference internal" href="#asserting-absent">asserting_absent</a></li>
<li><a class="reference internal" href="#asserting-bool">asserting_bool</a></li>
<li><a class="reference internal" href="#asserting-boolean">asserting_boolean</a></li>
<li><a class="reference internal" href="#asserting-empty">asserting_empty</a></li>
<li><a class="reference internal" href="#asserting-empty-map">asserting_empty_map</a></li>
<li><a class="reference internal" href="#asserting-float">asserting_float</a></li>
<li><a class="reference internal" href="#asserting-int">asserting_int</a></li>
<li><a class="reference internal" href="#asserting-map">asserting_map</a></li>
<li><a class="reference internal" href="#asserting-nonempty-map">asserting_nonempty_map</a></li>
<li><a class="reference internal" href="#asserting-not-empty">asserting_not_empty</a></li>
<li><a class="reference internal" href="#asserting-not-map">asserting_not_map</a></li>
<li><a class="reference internal" href="#asserting-not-null">asserting_not_null</a></li>
<li><a class="reference internal" href="#asserting-null">asserting_null</a></li>
<li><a class="reference internal" href="#asserting-numeric">asserting_numeric</a></li>
<li><a class="reference internal" href="#asserting-present">asserting_present</a></li>
<li><a class="reference internal" href="#asserting-string">asserting_string</a></li>
<li><a class="reference internal" href="#atan">atan</a></li>
<li><a class="reference internal" href="#atan2">atan2</a></li>
<li><a class="reference internal" href="#atanh">atanh</a></li>
<li><a class="reference internal" href="#bitcount">bitcount</a></li>
<li><a class="reference internal" href="#boolean">boolean</a></li>
<li><a class="reference internal" href="#capitalize">capitalize</a></li>
<li><a class="reference internal" href="#cbrt">cbrt</a></li>
<li><a class="reference internal" href="#ceil">ceil</a></li>
<li><a class="reference internal" href="#clean-whitespace">clean_whitespace</a></li>
<li><a class="reference internal" href="#collapse-whitespace">collapse_whitespace</a></li>
<li><a class="reference internal" href="#cos">cos</a></li>
<li><a class="reference internal" href="#cosh">cosh</a></li>
<li><a class="reference internal" href="#depth">depth</a></li>
<li><a class="reference internal" href="#dhms2fsec">dhms2fsec</a></li>
<li><a class="reference internal" href="#dhms2sec">dhms2sec</a></li>
<li><a class="reference internal" href="#erf">erf</a></li>
<li><a class="reference internal" href="#erfc">erfc</a></li>
<li><a class="reference internal" href="#exp">exp</a></li>
<li><a class="reference internal" href="#expm1">expm1</a></li>
<li><a class="reference internal" href="#float">float</a></li>
<li><a class="reference internal" href="#floor">floor</a></li>
<li><a class="reference internal" href="#fmtnum">fmtnum</a></li>
<li><a class="reference internal" href="#fsec2dhms">fsec2dhms</a></li>
<li><a class="reference internal" href="#fsec2hms">fsec2hms</a></li>
<li><a class="reference internal" href="#gmt2sec">gmt2sec</a></li>
<li><a class="reference internal" href="#gsub">gsub</a></li>
<li><a class="reference internal" href="#haskey">haskey</a></li>
<li><a class="reference internal" href="#hexfmt">hexfmt</a></li>
<li><a class="reference internal" href="#hms2fsec">hms2fsec</a></li>
<li><a class="reference internal" href="#hms2sec">hms2sec</a></li>
<li><a class="reference internal" href="#int">int</a></li>
<li><a class="reference internal" href="#invqnorm">invqnorm</a></li>
<li><a class="reference internal" href="#is-absent">is_absent</a></li>
<li><a class="reference internal" href="#is-bool">is_bool</a></li>
<li><a class="reference internal" href="#is-boolean">is_boolean</a></li>
<li><a class="reference internal" href="#is-empty">is_empty</a></li>
<li><a class="reference internal" href="#is-empty-map">is_empty_map</a></li>
<li><a class="reference internal" href="#is-float">is_float</a></li>
<li><a class="reference internal" href="#is-int">is_int</a></li>
<li><a class="reference internal" href="#is-map">is_map</a></li>
<li><a class="reference internal" href="#is-nonempty-map">is_nonempty_map</a></li>
<li><a class="reference internal" href="#is-not-empty">is_not_empty</a></li>
<li><a class="reference internal" href="#is-not-map">is_not_map</a></li>
<li><a class="reference internal" href="#is-not-null">is_not_null</a></li>
<li><a class="reference internal" href="#is-null">is_null</a></li>
<li><a class="reference internal" href="#is-numeric">is_numeric</a></li>
<li><a class="reference internal" href="#is-present">is_present</a></li>
<li><a class="reference internal" href="#is-string">is_string</a></li>
<li><a class="reference internal" href="#joink">joink</a></li>
<li><a class="reference internal" href="#joinkv">joinkv</a></li>
<li><a class="reference internal" href="#joinv">joinv</a></li>
<li><a class="reference internal" href="#leafcount">leafcount</a></li>
<li><a class="reference internal" href="#length">length</a></li>
<li><a class="reference internal" href="#localtime2sec">localtime2sec</a></li>
<li><a class="reference internal" href="#log">log</a></li>
<li><a class="reference internal" href="#log10">log10</a></li>
<li><a class="reference internal" href="#log1p">log1p</a></li>
<li><a class="reference internal" href="#logifit">logifit</a></li>
<li><a class="reference internal" href="#lstrip">lstrip</a></li>
<li><a class="reference internal" href="#madd">madd</a></li>
<li><a class="reference internal" href="#mapdiff">mapdiff</a></li>
<li><a class="reference internal" href="#mapexcept">mapexcept</a></li>
<li><a class="reference internal" href="#mapselect">mapselect</a></li>
<li><a class="reference internal" href="#mapsum">mapsum</a></li>
<li><a class="reference internal" href="#max">max</a></li>
<li><a class="reference internal" href="#mexp">mexp</a></li>
<li><a class="reference internal" href="#min">min</a></li>
<li><a class="reference internal" href="#mmul">mmul</a></li>
<li><a class="reference internal" href="#msub">msub</a></li>
<li><a class="reference internal" href="#pow">pow</a></li>
<li><a class="reference internal" href="#qnorm">qnorm</a></li>
<li><a class="reference internal" href="#regextract">regextract</a></li>
<li><a class="reference internal" href="#regextract-or-else">regextract_or_else</a></li>
<li><a class="reference internal" href="#round">round</a></li>
<li><a class="reference internal" href="#roundm">roundm</a></li>
<li><a class="reference internal" href="#rstrip">rstrip</a></li>
<li><a class="reference internal" href="#sec2dhms">sec2dhms</a></li>
<li><a class="reference internal" href="#sec2gmt">sec2gmt</a></li>
<li><a class="reference internal" href="#sec2gmtdate">sec2gmtdate</a></li>
<li><a class="reference internal" href="#sec2hms">sec2hms</a></li>
<li><a class="reference internal" href="#sec2localdate">sec2localdate</a></li>
<li><a class="reference internal" href="#sec2localtime">sec2localtime</a></li>
<li><a class="reference internal" href="#sgn">sgn</a></li>
<li><a class="reference internal" href="#sin">sin</a></li>
<li><a class="reference internal" href="#sinh">sinh</a></li>
<li><a class="reference internal" href="#splitkv">splitkv</a></li>
<li><a class="reference internal" href="#splitkvx">splitkvx</a></li>
<li><a class="reference internal" href="#splitnv">splitnv</a></li>
<li><a class="reference internal" href="#splitnvx">splitnvx</a></li>
<li><a class="reference internal" href="#sqrt">sqrt</a></li>
<li><a class="reference internal" href="#ssub">ssub</a></li>
<li><a class="reference internal" href="#strftime">strftime</a></li>
<li><a class="reference internal" href="#strftime-local">strftime_local</a></li>
<li><a class="reference internal" href="#string">string</a></li>
<li><a class="reference internal" href="#strip">strip</a></li>
<li><a class="reference internal" href="#strlen">strlen</a></li>
<li><a class="reference internal" href="#strptime">strptime</a></li>
<li><a class="reference internal" href="#strptime-local">strptime_local</a></li>
<li><a class="reference internal" href="#sub">sub</a></li>
<li><a class="reference internal" href="#substr">substr</a></li>
<li><a class="reference internal" href="#system">system</a></li>
<li><a class="reference internal" href="#systime">systime</a></li>
<li><a class="reference internal" href="#tan">tan</a></li>
<li><a class="reference internal" href="#tanh">tanh</a></li>
<li><a class="reference internal" href="#tolower">tolower</a></li>
<li><a class="reference internal" href="#toupper">toupper</a></li>
<li><a class="reference internal" href="#truncate">truncate</a></li>
<li><a class="reference internal" href="#typeof">typeof</a></li>
<li><a class="reference internal" href="#urand">urand</a></li>
<li><a class="reference internal" href="#urand32">urand32</a></li>
<li><a class="reference internal" href="#urandint">urandint</a></li>
<li><a class="reference internal" href="#urandrange">urandrange</a></li>
</ul>
</li>
<li><a class="reference internal" href="#user-defined-functions-and-subroutines">User-defined functions and subroutines</a><ul>
<li><a class="reference internal" href="#user-defined-functions">User-defined functions</a></li>
<li><a class="reference internal" href="#user-defined-subroutines">User-defined subroutines</a></li>
</ul>
</li>
<li><a class="reference internal" href="#errors-and-transparency">Errors and transparency</a></li>
<li><a class="reference internal" href="#a-note-on-the-complexity-of-miller-s-expression-language">A note on the complexity of Millers expression language</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="reference-verbs.html"
title="previous chapter">Verbs reference</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="manpage.html"
title="next chapter">Manpage</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/reference-dsl.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="manpage.html" title="Manpage"
>next</a> |</li>
<li class="right" >
<a href="reference-verbs.html" title="Verbs reference"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Miller 5.10.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">DSL reference</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, John Kerl.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>