Thun/docs/reference/mkref/FuncRef.html

2892 lines
93 KiB
HTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Functor Reference</title>
<style>
html {
line-height: 1.5;
font-family: Georgia, serif;
font-size: 20px;
color: #1a1a1a;
background-color: #fdfdfd;
}
body {
margin: 0 auto;
max-width: 36em;
padding-left: 50px;
padding-right: 50px;
padding-top: 50px;
padding-bottom: 50px;
hyphens: auto;
overflow-wrap: break-word;
text-rendering: optimizeLegibility;
font-kerning: normal;
}
@media (max-width: 600px) {
body {
font-size: 0.9em;
padding: 1em;
}
}
@media print {
body {
background-color: transparent;
color: black;
font-size: 12pt;
}
p, h2, h3 {
orphans: 3;
widows: 3;
}
h2, h3, h4 {
page-break-after: avoid;
}
}
p {
margin: 1em 0;
}
a {
color: #1a1a1a;
}
a:visited {
color: #1a1a1a;
}
img {
max-width: 100%;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 1.4em;
}
h5, h6 {
font-size: 1em;
font-style: italic;
}
h6 {
font-weight: normal;
}
ol, ul {
padding-left: 1.7em;
margin-top: 1em;
}
li > ol, li > ul {
margin-top: 0;
}
blockquote {
margin: 1em 0 1em 1.7em;
padding-left: 1em;
border-left: 2px solid #e6e6e6;
color: #606060;
}
code {
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
font-size: 85%;
margin: 0;
}
pre {
margin: 1em 0;
overflow: auto;
}
pre code {
padding: 0;
overflow: visible;
overflow-wrap: normal;
}
.sourceCode {
background-color: transparent;
overflow: visible;
}
hr {
background-color: #1a1a1a;
border: none;
height: 1px;
margin: 1em 0;
}
table {
margin: 1em 0;
border-collapse: collapse;
width: 100%;
overflow-x: auto;
display: block;
font-variant-numeric: lining-nums tabular-nums;
}
table caption {
margin-bottom: 0.75em;
}
tbody {
margin-top: 0.5em;
border-top: 1px solid #1a1a1a;
border-bottom: 1px solid #1a1a1a;
}
th {
border-top: 1px solid #1a1a1a;
padding: 0.25em 0.5em 0.25em 0.5em;
}
td {
padding: 0.125em 0.5em 0.25em 0.5em;
}
header {
margin-bottom: 4em;
text-align: center;
}
#TOC li {
list-style: none;
}
#TOC a:not(:hover) {
text-decoration: none;
}
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<header id="title-block-header">
<h1 class="title">Functor Reference</h1>
</header>
<nav id="TOC" role="doc-toc">
<ul>
<li><a href="#section">&amp;</a></li>
<li><a href="#section-1">&amp;&amp;</a></li>
<li><a href="#section-2">*</a></li>
<li><a href="#section-3">&#x2022;</a></li>
<li><a href="#section-4">^</a></li>
<li><a href="#section-5">=</a></li>
<li><a href="#section-6">!=</a></li>
<li><a href="#section-7">!-</a></li>
<li><a href="#section-8">&gt;</a></li>
<li><a href="#section-9">&gt;=</a></li>
<li><a href="#section-10">&gt;&gt;</a></li>
<li><a href="#section-11">-</a></li>
<li><a href="#section-12">&#x2013;</a></li>
<li><a href="#section-13">&lt;</a></li>
<li><a href="#section-14">&lt;=</a></li>
<li><a href="#section-15">&lt;&gt;</a></li>
<li><a href="#section-16">&lt;{}</a></li>
<li><a href="#section-17">&lt;&lt;</a></li>
<li><a href="#section-18">&lt;&lt;{}</a></li>
<li><a href="#section-19">%</a></li>
<li><a href="#section-20">+</a></li>
<li><a href="#section-21">++</a></li>
<li><a href="#section-22">?</a></li>
<li><a href="#section-23">/</a></li>
<li><a href="#section-24">//</a></li>
<li><a href="#floor">/floor</a></li>
<li><a href="#section-25">||</a></li>
<li><a href="#abs">abs</a></li>
<li><a href="#add">add</a></li>
<li><a href="#anamorphism">anamorphism</a></li>
<li><a href="#and">and</a></li>
<li><a href="#app1">app1</a></li>
<li><a href="#app2">app2</a></li>
<li><a href="#app3">app3</a></li>
<li><a href="#appn">appN</a></li>
<li><a href="#at">at</a></li>
<li><a href="#average">average</a></li>
<li><a href="#b">b</a></li>
<li><a href="#binary">binary</a></li>
<li><a href="#bool">bool</a></li>
<li><a href="#branch">branch</a></li>
<li><a href="#ccccons">ccccons</a></li>
<li><a href="#ccons">ccons</a></li>
<li><a href="#choice">choice</a></li>
<li><a href="#clear">clear</a></li>
<li><a href="#cleave">cleave</a></li>
<li><a href="#clop">clop</a></li>
<li><a href="#cmp">cmp</a></li>
<li><a href="#codi">codi</a></li>
<li><a href="#codireco">codireco</a></li>
<li><a href="#concat">concat</a></li>
<li><a href="#cond">cond</a></li>
<li><a href="#cons">cons</a></li>
<li><a href="#dinfrirst">dinfrirst</a></li>
<li><a href="#dip">dip</a></li>
<li><a href="#dipd">dipd</a></li>
<li><a href="#dipdd">dipdd</a></li>
<li><a href="#disenstacken">disenstacken</a></li>
<li><a href="#div">div</a></li>
<li><a href="#divmod">divmod</a></li>
<li><a href="#down_to_zero">down_to_zero</a></li>
<li><a href="#drop">drop</a></li>
<li><a href="#dup">dup</a></li>
<li><a href="#dupd">dupd</a></li>
<li><a href="#dupdd">dupdd</a></li>
<li><a href="#dupdip">dupdip</a></li>
<li><a href="#dupdipd">dupdipd</a></li>
<li><a href="#enstacken">enstacken</a></li>
<li><a href="#eq">eq</a></li>
<li><a href="#first">first</a></li>
<li><a href="#first_two">first_two</a></li>
<li><a href="#flatten">flatten</a></li>
<li><a href="#floor-1">floor</a></li>
<li><a href="#floordiv">floordiv</a></li>
<li><a href="#fork">fork</a></li>
<li><a href="#fourth">fourth</a></li>
<li><a href="#gcd">gcd</a></li>
<li><a href="#gcd2">gcd2</a></li>
<li><a href="#ge">ge</a></li>
<li><a href="#genrec">genrec</a></li>
<li><a href="#getitem">getitem</a></li>
<li><a href="#grabn">grabN</a></li>
<li><a href="#grba">grba</a></li>
<li><a href="#gt">gt</a></li>
<li><a href="#help">help</a></li>
<li><a href="#hypot">hypot</a></li>
<li><a href="#i">i</a></li>
<li><a href="#id">id</a></li>
<li><a href="#ifte">ifte</a></li>
<li><a href="#ii">ii</a></li>
<li><a href="#infra">infra</a></li>
<li><a href="#infrst">infrst</a></li>
<li><a href="#inscribe">inscribe</a></li>
<li><a href="#le">le</a></li>
<li><a href="#loop">loop</a></li>
<li><a href="#lshift">lshift</a></li>
<li><a href="#lt">lt</a></li>
<li><a href="#make_generator">make_generator</a></li>
<li><a href="#map">map</a></li>
<li><a href="#max">max</a></li>
<li><a href="#min">min</a></li>
<li><a href="#mod">mod</a></li>
<li><a href="#modulus">modulus</a></li>
<li><a href="#mul">mul</a></li>
<li><a href="#ne">ne</a></li>
<li><a href="#neg">neg</a></li>
<li><a href="#not">not</a></li>
<li><a href="#section-26">!-</a></li>
<li><a href="#nulco">nulco</a></li>
<li><a href="#nullary">nullary</a></li>
<li><a href="#of">of</a></li>
<li><a href="#or">or</a></li>
<li><a href="#over">over</a></li>
<li><a href="#pam">pam</a></li>
<li><a href="#pick">pick</a></li>
<li><a href="#pm">pm</a></li>
<li><a href="#pop">pop</a></li>
<li><a href="#popd">popd</a></li>
<li><a href="#popdd">popdd</a></li>
<li><a href="#popop">popop</a></li>
<li><a href="#popopd">popopd</a></li>
<li><a href="#popopdd">popopdd</a></li>
<li><a href="#popopop">popopop</a></li>
<li><a href="#pow">pow</a></li>
<li><a href="#pred">pred</a></li>
<li><a href="#primrec">primrec</a></li>
<li><a href="#product">product</a></li>
<li><a href="#quoted">quoted</a></li>
<li><a href="#range">range</a></li>
<li><a href="#range_to_zero">range_to_zero</a></li>
<li><a href="#reco">reco</a></li>
<li><a href="#rem">rem</a></li>
<li><a href="#remainder">remainder</a></li>
<li><a href="#remove">remove</a></li>
<li><a href="#rest">rest</a></li>
<li><a href="#reverse">reverse</a></li>
<li><a href="#rolldown">rolldown</a></li>
<li><a href="#rollup">rollup</a></li>
<li><a href="#roll">roll&gt;</a></li>
<li><a href="#roll-1">roll&lt;</a></li>
<li><a href="#round">round</a></li>
<li><a href="#rrest">rrest</a></li>
<li><a href="#rshift">rshift</a></li>
<li><a href="#run">run</a></li>
<li><a href="#second">second</a></li>
<li><a href="#select">select</a></li>
<li><a href="#sharing">sharing</a></li>
<li><a href="#shift">shift</a></li>
<li><a href="#shunt">shunt</a></li>
<li><a href="#size">size</a></li>
<li><a href="#sort">sort</a></li>
<li><a href="#spiral_next">spiral_next</a></li>
<li><a href="#split_at">split_at</a></li>
<li><a href="#split_list">split_list</a></li>
<li><a href="#sqr">sqr</a></li>
<li><a href="#sqrt">sqrt</a></li>
<li><a href="#stack">stack</a></li>
<li><a href="#stackd">stackd</a></li>
<li><a href="#step">step</a></li>
<li><a href="#step_zero">step_zero</a></li>
<li><a href="#stuncons">stuncons</a></li>
<li><a href="#stununcons">stununcons</a></li>
<li><a href="#sub">sub</a></li>
<li><a href="#succ">succ</a></li>
<li><a href="#sum">sum</a></li>
<li><a href="#swaack">swaack</a></li>
<li><a href="#swap">swap</a></li>
<li><a href="#swapd">swapd</a></li>
<li><a href="#swoncat">swoncat</a></li>
<li><a href="#swons">swons</a></li>
<li><a href="#tailrec">tailrec</a></li>
<li><a href="#take">take</a></li>
<li><a href="#ternary">ternary</a></li>
<li><a href="#third">third</a></li>
<li><a href="#times">times</a></li>
<li><a href="#truthy">truthy</a></li>
<li><a href="#tuck">tuck</a></li>
<li><a href="#unary">unary</a></li>
<li><a href="#uncons">uncons</a></li>
<li><a href="#unique">unique</a></li>
<li><a href="#unit">unit</a></li>
<li><a href="#unquoted">unquoted</a></li>
<li><a href="#unswons">unswons</a></li>
<li><a href="#void">void</a></li>
<li><a href="#warranty">warranty</a></li>
<li><a href="#while">while</a></li>
<li><a href="#words">words</a></li>
<li><a href="#x">x</a></li>
<li><a href="#xor">xor</a></li>
<li><a href="#zip">zip</a></li>
</ul>
</nav>
<p>Version -10.0.0</p>
<p>Each function, combinator, or definition should be documented here.</p>
<hr />
<h2 id="section">&amp;</h2>
<p>See <a href="#and">and</a>.</p>
<hr />
<h2 id="section-1">&amp;&amp;</h2>
<p>Combinator</p>
<p>Short-circuiting Boolean AND</p>
<p>Accept two quoted programs, run the first and expect a Boolean value, if it&#x2019;s <code>true</code> pop it and run the second program (which should also return a Boolean value) otherwise pop the second program (leaving <code>false</code> on the stack.)</p>
<pre><code> [A] [B] &amp;&amp;
---------------- true
B
[A] [B] &amp;&amp;
---------------- false
false</code></pre>
<h3 id="definition">Definition</h3>
<pre><code>nulco [nullary [false]] dip branch</code></pre>
<h3 id="derivation">Derivation</h3>
<p>TODO: this is derived in one of the notebooks I think, look it up and link to it, or copy the content here.</p>
<h3 id="discussion">Discussion</h3>
<p>This is seldom useful, I suspect, but this way you have it.</p>
<h3 id="crosslinks">Crosslinks</h3>
<p><a href="#section-25">||</a></p>
<hr />
<h2 id="section-2">*</h2>
<p>See <a href="#mul">mul</a>.</p>
<hr />
<h2 id="section-3">&#x2022;</h2>
<p>See <a href="#id">id</a>.</p>
<hr />
<h2 id="section-4">^</h2>
<p>See <a href="#xor">xor</a>.</p>
<hr />
<h2 id="section-5">=</h2>
<p>See <a href="#eq">eq</a>.</p>
<hr />
<h2 id="section-6">!=</h2>
<p>See <a href="#ne">ne</a>.</p>
<hr />
<h2 id="section-7">!-</h2>
<p>Function</p>
<p>Not negative.</p>
<pre><code> n !-
----------- n &lt; 0
false
n !-
---------- n &gt;= 0
true</code></pre>
<h3 id="definition-1">Definition</h3>
<pre><code>0 \&gt;=</code></pre>
<h3 id="discussion-1">Discussion</h3>
<p>Return a Boolean value indicating if a number is greater than or equal to zero.</p>
<hr />
<h2 id="section-8">&gt;</h2>
<p>See <a href="#gt">gt</a>.</p>
<hr />
<h2 id="section-9">&gt;=</h2>
<p>See <a href="#ge">ge</a>.</p>
<hr />
<h2 id="section-10">&gt;&gt;</h2>
<p>See <a href="#rshift">rshift</a>.</p>
<hr />
<h2 id="section-11">-</h2>
<p>See <a href="#sub">sub</a>.</p>
<hr />
<h2 id="section-12">&#x2013;</h2>
<p>See <a href="#pred">pred</a>.</p>
<hr />
<h2 id="section-13">&lt;</h2>
<p>See <a href="#lt">lt</a>.</p>
<hr />
<h2 id="section-14">&lt;=</h2>
<p>See <a href="#le">le</a>.</p>
<hr />
<h2 id="section-15">&lt;&gt;</h2>
<p>See <a href="#ne">ne</a>.</p>
<hr />
<h2 id="section-16">&lt;{}</h2>
<p>Function</p>
<pre><code> ... a &lt;{}
----------------
... [] a</code></pre>
<h3 id="definition-2">Definition</h3>
<pre><code>[] swap</code></pre>
<h3 id="discussion-2">Discussion</h3>
<p>Tuck an empty list just under the first item on the stack.</p>
<h3 id="crosslinks-1">Crosslinks</h3>
<p><a href="#section-18">&lt;&lt;{}</a></p>
<hr />
<h2 id="section-17">&lt;&lt;</h2>
<p>See <a href="#lshift">lshift</a>.</p>
<hr />
<h2 id="section-18">&lt;&lt;{}</h2>
<p>Function</p>
<pre><code> ... b a &lt;{}
-----------------
... [] b a</code></pre>
<h3 id="definition-3">Definition</h3>
<pre><code>[] rollup</code></pre>
<h3 id="discussion-3">Discussion</h3>
<p>Tuck an empty list just under the first two items on the stack.</p>
<h3 id="crosslinks-2">Crosslinks</h3>
<p><a href="#section-16">&lt;{}</a></p>
<hr />
<h2 id="section-19">%</h2>
<p>See <a href="#mod">mod</a>.</p>
<hr />
<h2 id="section-20">+</h2>
<p>See <a href="#add">add</a>.</p>
<hr />
<h2 id="section-21">++</h2>
<p>See <a href="#succ">succ</a>.</p>
<hr />
<h2 id="section-22">?</h2>
<p>Function</p>
<p>Is the item on the top of the stack &#x201C;truthy&#x201D;?</p>
<h3 id="definition-4">Definition</h3>
<blockquote>
<p><a href="#dup">dup</a> <a href="#bool">bool</a></p>
</blockquote>
<h3 id="discussion-4">Discussion</h3>
<p>You often want to test the truth value of an item on the stack without consuming the item.</p>
<h3 id="crosslinks-3">Crosslinks</h3>
<p><a href="#bool">bool</a></p>
<hr />
<h2 id="section-23">/</h2>
<p>See <a href="#floordiv">floordiv</a>.</p>
<hr />
<h2 id="section-24">//</h2>
<p>See <a href="#floordiv">floordiv</a>.</p>
<hr />
<h2 id="floor">/floor</h2>
<p>See <a href="#floordiv">floordiv</a>.</p>
<hr />
<h2 id="section-25">||</h2>
<p>Combinator</p>
<p>Short-circuiting Boolean OR</p>
<h3 id="definition-5">Definition</h3>
<blockquote>
<p><a href="#nulco">nulco</a> [<a href="#nullary">nullary</a>] <a href="#dip">dip</a> [true] <a href="#branch">branch</a></p>
</blockquote>
<h3 id="discussion-5">Discussion</h3>
<p>Accept two quoted programs, run the first and expect a Boolean value, if it&#x2019;s <code>false</code> pop it and run the second program (which should also return a Boolean value) otherwise pop the second program (leaving <code>true</code> on the stack.)</p>
<pre><code> [A] [B] ||
---------------- A -&gt; false
B
[A] [B] ||
---------------- A -&gt; true
true</code></pre>
<h3 id="crosslinks-4">Crosslinks</h3>
<p><a href="#section-1">&amp;&amp;</a></p>
<hr />
<h2 id="abs">abs</h2>
<p>Function</p>
<p>Return the absolute value of the argument.</p>
<h3 id="definition-6">Definition</h3>
<blockquote>
<p><a href="#dup">dup</a> 0 &lt; [] [<a href="#neg">neg</a>] <a href="#branch">branch</a></p>
</blockquote>
<hr />
<h2 id="add">add</h2>
<p>Basis Function</p>
<p>Add two numbers together: a + b.</p>
<hr />
<h2 id="anamorphism">anamorphism</h2>
<p>Combinator</p>
<p>Build a list of values from a generator program <code>G</code> and a stopping predicate <code>P</code>.</p>
<pre><code> [P] [G] anamorphism
-----------------------------------------
[P] [pop []] [G] [dip swons] genrec</code></pre>
<h3 id="definition-7">Definition</h3>
<blockquote>
<p>[<a href="#pop">pop</a> []] <a href="#swap">swap</a> [<a href="#dip">dip</a> <a href="#swons">swons</a>] <a href="#genrec">genrec</a></p>
</blockquote>
<h3 id="example">Example</h3>
<p>The <code>range</code> function generates a list of the integers from 0 to n - 1:</p>
<blockquote>
<p>[0 &lt;=] [-- dup] anamorphism</p>
</blockquote>
<h3 id="discussion-6">Discussion</h3>
<p>See the <a href="https://joypy.osdn.io/notebooks/Recursion_Combinators.html">Recursion Combinators notebook</a>.</p>
<hr />
<h2 id="and">and</h2>
<p>Basis Function</p>
<p>Logical bit-wise AND.</p>
<h3 id="crosslinks-5">Crosslinks</h3>
<p><a href="#or">or</a> <a href="#xor">xor</a></p>
<hr />
<h2 id="app1">app1</h2>
<p>&#x201C;apply one&#x201D;</p>
<p>Combinator</p>
<p>Given a quoted program on TOS and anything as the second stack item run the program without disturbing the stack and replace the two args with the first result of the program.</p>
<pre><code> ... x [Q] app1
---------------------------------
... [x ...] [Q] infra first</code></pre>
<p>This is the same effect as the <a href="#unary">unary</a> combinator.</p>
<h3 id="definition-8">Definition</h3>
<blockquote>
<p><a href="#nullary">nullary</a> <a href="#popd">popd</a></p>
</blockquote>
<h3 id="discussion-7">Discussion</h3>
<p>Just a specialization of <code>nullary</code> really. Its parallelizable cousins are more useful.</p>
<h3 id="crosslinks-6">Crosslinks</h3>
<p><a href="#app2">app2</a> <a href="#app3">app3</a> <a href="#appN">appN</a> <a href="#unary">unary</a></p>
<hr />
<h2 id="app2">app2</h2>
<p>Combinator</p>
<p>Like <a href="#app1">app1</a> with two items.</p>
<pre><code> ... y x [Q] . app2
-----------------------------------
... [y ...] [Q] . infra first
[x ...] [Q] infra first</code></pre>
<h3 id="definition-9">Definition</h3>
<blockquote>
<p>[<a href="#grba">grba</a> <a href="#swap">swap</a> <a href="#grba">grba</a> <a href="#swap">swap</a>] <a href="#dip">dip</a> [<a href="#infrst">infrst</a>] <a href="#cons">cons</a> <a href="#ii">ii</a></p>
</blockquote>
<h3 id="discussion-8">Discussion</h3>
<p>Unlike <a href="#app1">app1</a>, which is essentially an alias for <a href="#unary">unary</a>, this function is not the same as <a href="#binary">binary</a>. Instead of running one program using exactly two items from the stack and pushing one result (as <a href="#binary">binary</a> does) this function takes two items from the stack and runs the program twice, separately for each of the items, then puts both results onto the stack.</p>
<p>This is not currently implemented as parallel processes but it can (and should) be done.</p>
<h3 id="crosslinks-7">Crosslinks</h3>
<p><a href="#app1">app1</a> <a href="#app3">app3</a> <a href="#appN">appN</a> <a href="#unary">unary</a></p>
<hr />
<h2 id="app3">app3</h2>
<p>Combinator</p>
<p>Like <a href="#app1">app1</a> with three items.</p>
<pre><code> ... z y x [Q] . app3
-----------------------------------
... [z ...] [Q] . infra first
[y ...] [Q] infra first
[x ...] [Q] infra first</code></pre>
<h3 id="definition-10">Definition</h3>
<blockquote>
<p>3 <a href="#appn">appN</a></p>
</blockquote>
<h3 id="discussion-9">Discussion</h3>
<p>See <a href="#app2">app2</a>.</p>
<h3 id="crosslinks-8">Crosslinks</h3>
<p><a href="#app1">app1</a> <a href="#app2">app2</a> <a href="#appN">appN</a> <a href="#unary">unary</a></p>
<hr />
<h2 id="appn">appN</h2>
<p>Combinator</p>
<p>Like <a href="#app1">app1</a> with any number of items.</p>
<pre><code> ... xN ... x2 x1 x0 [Q] n . appN
--------------------------------------
... [xN ...] [Q] . infra first
...
[x2 ...] [Q] infra first
[x1 ...] [Q] infra first
[x0 ...] [Q] infra first</code></pre>
<h3 id="definition-11">Definition</h3>
<blockquote>
<p>[<a href="#grabn">grabN</a>] <a href="#codi">codi</a> <a href="#map">map</a> <a href="#disenstacken">disenstacken</a></p>
</blockquote>
<h3 id="discussion-10">Discussion</h3>
<p>This function takes a quoted function <code>Q</code> and an integer and runs the function that many times on that many stack items. See also <a href="#app2">app2</a>.</p>
<h3 id="crosslinks-9">Crosslinks</h3>
<p><a href="#app1">app1</a> <a href="#app2">app2</a> <a href="#app3">app3</a> <a href="#unary">unary</a></p>
<hr />
<h2 id="at">at</h2>
<p>See <a href="#getitem">getitem</a>.</p>
<hr />
<h2 id="average">average</h2>
<p>Function</p>
<p>Compute the average of a list of numbers. (Currently broken until I can figure out what to do about &#x201C;numeric tower&#x201D; in Thun.)</p>
<h3 id="definition-12">Definition</h3>
<blockquote>
<p>[<a href="#sum">sum</a>] [<a href="#size">size</a>] <a href="#cleave">cleave</a> <a href="#section-23">/</a></p>
</blockquote>
<h3 id="discussion-11">Discussion</h3>
<p>Theoretically this function would compute the sum and the size in two separate threads, then divide. This works but a compiled version would probably do better to sum and count the list once, in one thread, eh?</p>
<p>As an exercise in Functional Programming in Joy it would be fun to convert this into a catamorphism. See the <a href="https://joypy.osdn.io/notebooks/Recursion_Combinators.html">Recursion Combinators notebook</a>.</p>
<hr />
<h2 id="b">b</h2>
<p>Combinator</p>
<p>Run two quoted programs</p>
<pre><code> [P] [Q] b
---------------
P Q</code></pre>
<h3 id="definition-13">Definition</h3>
<blockquote>
<p>[<a href="#i">i</a>] <a href="#dip">dip</a> <a href="#i">i</a></p>
</blockquote>
<h3 id="discussion-12">Discussion</h3>
<p>This combinator may seem trivial but it comes in handy.</p>
<h3 id="crosslinks-10">Crosslinks</h3>
<p><a href="#dupdip">dupdip</a> <a href="#ii">ii</a></p>
<hr />
<h2 id="binary">binary</h2>
<p>Combinator</p>
<p>Run a quoted program using exactly two stack values and leave the first item of the result on the stack.</p>
<pre><code> ... y x [P] binary
-----------------------
... a</code></pre>
<h3 id="definition-14">Definition</h3>
<blockquote>
<p><a href="#unary">unary</a> <a href="#popd">popd</a></p>
</blockquote>
<h3 id="discussion-13">Discussion</h3>
<p>Runs any other quoted function and returns its first result while consuming exactly two items from the stack.</p>
<h3 id="crosslinks-11">Crosslinks</h3>
<p><a href="#nullary">nullary</a> <a href="#ternary">ternary</a> <a href="#unary">unary</a></p>
<hr />
<h2 id="bool">bool</h2>
<p>Basis Function</p>
<p>Convert the item on the top of the stack to a Boolean value.</p>
<h3 id="discussion-14">Discussion</h3>
<p>For integers 0 is <code>false</code> and any other number is <code>true</code>; for lists the empty list is <code>false</code> and all other lists are <code>true</code>.</p>
<h3 id="crosslinks-12">Crosslinks</h3>
<p><a href="#not">not</a></p>
<hr />
<h2 id="branch">branch</h2>
<p>Basis Combinator</p>
<p>Use a Boolean value to select and run one of two quoted programs.</p>
<pre><code> false [F] [T] branch
--------------------------
F
true [F] [T] branch
-------------------------
T</code></pre>
<h3 id="definition-15">Definition</h3>
<blockquote>
<p><a href="#rolldown">rolldown</a> <a href="#choice">choice</a> <a href="#i">i</a></p>
</blockquote>
<h3 id="discussion-15">Discussion</h3>
<p>This is one of the fundamental operations (although it can be defined in terms of <a href="#choice">choice</a> as above). The more common &#x201C;if..then..else&#x201D; construct <a href="#ifte">ifte</a> adds a predicate function that is evaluated <a href="#nullary">nullary</a>.</p>
<h3 id="crosslinks-13">Crosslinks</h3>
<p><a href="#choice">choice</a> <a href="#ifte">ifte</a> <a href="#select">select</a></p>
<hr />
<h2 id="ccccons">ccccons</h2>
<p>Function</p>
<pre><code> a b c d [...] ccccons
---------------------------
[a b c d ...]</code></pre>
<p>Do <a href="#cons">cons</a> four times.</p>
<h3 id="definition-16">Definition</h3>
<blockquote>
<p><a href="#ccons">ccons</a> <a href="#ccons">ccons</a></p>
</blockquote>
<h3 id="crosslinks-14">Crosslinks</h3>
<p><a href="#ccons">ccons</a> <a href="#cons">cons</a> <a href="#times">times</a></p>
<hr />
<h2 id="ccons">ccons</h2>
<p>Function</p>
<pre><code> a b [...] ccons
---------------------
[a b ...]</code></pre>
<p>Do <a href="#cons">cons</a> two times.</p>
<h3 id="definition-17">Definition</h3>
<blockquote>
<p><a href="#cons">cons</a> <a href="#cons">cons</a></p>
</blockquote>
<h3 id="crosslinks-15">Crosslinks</h3>
<p><a href="#cons">cons</a> <a href="#ccons">ccons</a></p>
<hr />
<h2 id="choice">choice</h2>
<p>Basis Function</p>
<p>Use a Boolean value to select one of two items.</p>
<pre><code> a b false choice
----------------------
a
a b true choice
---------------------
b</code></pre>
<h3 id="definition-18">Definition</h3>
<blockquote>
<p>[<a href="#pop">pop</a>] [<a href="#popd">popd</a>] <a href="#branch">branch</a></p>
</blockquote>
<h3 id="discussion-16">Discussion</h3>
<p>It&#x2019;s a matter of taste whether you implement this in terms of <a href="#branch">branch</a> or the other way around.</p>
<h3 id="crosslinks-16">Crosslinks</h3>
<p><a href="#branch">branch</a> <a href="#select">select</a></p>
<hr />
<h2 id="clear">clear</h2>
<p>Basis Function</p>
<p>Clear everything from the stack.</p>
<h3 id="definition-19">Definition</h3>
<blockquote>
<p><a href="#stack">stack</a> <a href="#bool">bool</a> [<a href="#pop">pop</a> <a href="#stack">stack</a> <a href="#bool">bool</a>] <a href="#loop">loop</a></p>
</blockquote>
<h3 id="crosslinks-17">Crosslinks</h3>
<p><a href="#stack">stack</a> <a href="#swaack">swaack</a></p>
<hr />
<h2 id="cleave">cleave</h2>
<p>Combinator</p>
<p>Run two programs in parallel, consuming one additional item, and put their results on the stack.</p>
<pre><code> ... x [A] [B] cleave
------------------------
... a b</code></pre>
<h3 id="derivation-1">Derivation</h3>
<blockquote>
<p><a href="#fork">fork</a> <a href="#popdd">popdd</a></p>
</blockquote>
<h3 id="example-1">Example</h3>
<pre><code> 1 2 3 [+] [-] cleave
--------------------------
1 2 5 -1</code></pre>
<h3 id="discussion-17">Discussion</h3>
<p>One of a handful of useful parallel combinators.</p>
<h3 id="crosslinks-18">Crosslinks</h3>
<p><a href="#clop">clop</a> <a href="#fork">fork</a> <a href="#map">map</a></p>
<hr />
<h2 id="clop">clop</h2>
<p>Combinator</p>
<p>Run two programs in parallel, consuming two additional items, and put their results on the stack.</p>
<pre><code> ... x y [A] [B] clop
--------------------------
... a b</code></pre>
<h3 id="definition-20">Definition</h3>
<blockquote>
<p><a href="#cleave">cleave</a> <a href="#popdd">popdd</a></p>
</blockquote>
<h3 id="discussion-18">Discussion</h3>
<p>Like <a href="#cleave">cleave</a> but consumes an additional item from the stack.</p>
<pre><code> 1 2 3 4 [+] [-] clop
--------------------------
1 2 7 -1</code></pre>
<h3 id="crosslinks-19">Crosslinks</h3>
<p><a href="#cleave">cleave</a> <a href="#fork">fork</a> <a href="#map">map</a></p>
<hr />
<h2 id="cmp">cmp</h2>
<p>Combinator</p>
<p>Take two values and three quoted programs on the stack and run one of the three depending on the results of comparing the two values.</p>
<pre><code> a b [G] [E] [L] cmp
------------------------- a &gt; b
G
a b [G] [E] [L] cmp
------------------------- a = b
E
a b [G] [E] [L] cmp
------------------------- a &lt; b
L</code></pre>
<h3 id="discussion-19">Discussion</h3>
<p>This is useful sometimes, and you can <a href="#dup">dup</a> or <a href="#dupd">dupd</a> with two quoted programs to handle the cases when you just want to deal with <a href="#section-14">&lt;=</a> or <a href="#section-9">&gt;=</a> and not all three possibilities, e.g.:</p>
<pre><code>[G] [EL] dup cmp
[GE] [L] dupd cmp</code></pre>
<p>Or even:</p>
<pre><code>[GL] [E] over cmp</code></pre>
<h3 id="crosslinks-20">Crosslinks</h3>
<p>TODO: link to tree notebooks where this was used.</p>
<hr />
<h2 id="codi">codi</h2>
<p>Combinator</p>
<p>Take a quoted program from the stack, <a href="#cons">cons</a> the next item onto it, then <a href="#dip">dip</a> the whole thing under what was the third item on the stack.</p>
<pre><code> a b [F] . codi
--------------------
b . F a</code></pre>
<h3 id="definition-21">Definition</h3>
<blockquote>
<p><a href="#cons">cons</a> <a href="#dip">dip</a></p>
</blockquote>
<h3 id="discussion-20">Discussion</h3>
<p>This is one of those weirdly specific functions that turns out to be useful in a few places.</p>
<h3 id="crosslinks-21">Crosslinks</h3>
<p><a href="#appn">appN</a> <a href="#codireco">codireco</a></p>
<hr />
<h2 id="codireco">codireco</h2>
<p>Combinator</p>
<p>This is part of the <a href="#make_generator">make_generator</a> function. You would not use this combinator directly.</p>
<h3 id="definition-22">Definition</h3>
<blockquote>
<p><a href="#codi">codi</a> <a href="#reco">reco</a></p>
</blockquote>
<h3 id="discussion-21">Discussion</h3>
<p>See <a href="#make_generator">make_generator</a> and the <a href="https://joypy.osdn.io/notebooks/Generator_Programs.html#an-interesting-variation">&#x201C;Using <code>x</code> to Generate Values&#x201D; notebook</a> as well as <a href="https://www.kevinalbrecht.com/code/joy-mirror/j05cmp.html">Recursion Theory and Joy</a> by Manfred von Thun.</p>
<h3 id="crosslinks-22">Crosslinks</h3>
<p><a href="#make_generator">make_generator</a></p>
<hr />
<h2 id="concat">concat</h2>
<p>Function</p>
<p>Concatinate two lists.</p>
<pre><code> [a b c] [d e f] concat
----------------------------
[a b c d e f]</code></pre>
<h3 id="crosslinks-23">Crosslinks</h3>
<p><a href="#first">first</a> <a href="#first_two">first_two</a> <a href="#flatten">flatten</a> <a href="#fourth">fourth</a> <a href="#getitem">getitem</a> <a href="#remove">remove</a> <a href="#rest">rest</a> <a href="#reverse">reverse</a> <a href="#rrest">rrest</a> <a href="#second">second</a> <a href="#shift">shift</a> <a href="#shunt">shunt</a> <a href="#size">size</a> <a href="#sort">sort</a> <a href="#split_at">split_at</a> <a href="#split_list">split_list</a> <a href="#swaack">swaack</a> <a href="#third">third</a> <a href="#zip">zip</a></p>
<hr />
<h2 id="cond">cond</h2>
<p>Combinator</p>
<p>This combinator works like a case statement. It expects a single quote on the stack that must contain zero or more condition quotes and a default quote. Each condition quote should contain a quoted predicate followed by the function expression to run if that predicate returns <code>true</code>. If no predicates return <code>true</code> the default function runs.</p>
<pre><code>[
[ [Predicate0] Function0 ]
[ [Predicate1] Function1 ]
...
[ [PredicateN] FunctionN ]
[Default]
]
cond</code></pre>
<h3 id="discussion-22">Discussion</h3>
<p>It works by rewriting into a chain of nested <span class="title-ref">ifte</span> expressions, e.g.:</p>
<pre><code> [[[B0] T0] [[B1] T1] [D]] cond
-----------------------------------------
[B0] [T0] [[B1] [T1] [D] ifte] ifte</code></pre>
<h3 id="crosslinks-24">Crosslinks</h3>
<p><a href="#ifte">ifte</a></p>
<hr />
<h2 id="cons">cons</h2>
<p>Basis Function</p>
<p>Given an item and a list, append the item to the list to make a new list.</p>
<pre><code> a [...] cons
------------------
[a ...]</code></pre>
<h3 id="discussion-23">Discussion</h3>
<p>Cons is a <a href="https://en.wikipedia.org/wiki/Cons#Lists">venerable old function from Lisp</a>. Its inverse operation is <a href="#uncons">uncons</a>.</p>
<h3 id="crosslinks-25">Crosslinks</h3>
<p><a href="#uncons">uncons</a></p>
<hr />
<h2 id="dinfrirst">dinfrirst</h2>
<p>Combinator</p>
<p>Specialist function (that means I forgot what it does and why.)</p>
<h3 id="definition-23">Definition</h3>
<blockquote>
<p><a href="#dip">dip</a> <a href="#infrst">infrst</a></p>
</blockquote>
<hr />
<h2 id="dip">dip</h2>
<p>Basis Combinator</p>
<p>The <code>dip</code> combinator expects a quoted program on the stack and below it some item, it hoists the item into the expression and runs the program on the rest of the stack.</p>
<pre><code> ... x [Q] . dip
---------------------
... . Q x</code></pre>
<h3 id="discussion-24">Discussion</h3>
<p>This along with <a href="#infra">infra</a> are enough to update any datastructure. See the <a href="https://joypy.osdn.io/notebooks/Zipper.html">&#x201C;Traversing Datastructures with Zippers&#x201D; notebook</a>.</p>
<p>Note that the item that was on the top of the stack (<code>x</code> in the example above) will not be treated specially by the interpreter when it is reached again. This is something of a footgun. My advice is to avoid putting bare unquoted symbols onto the stack, but then you can&#x2019;t use symbols as &#x201C;atoms&#x201D; and also use <code>dip</code> and <code>infra</code> to operate on compound datastructures with atoms in them. This is a kind of side-effect of the Continuation-Passing Style. The <code>dip</code> combinator could &#x201C;set aside&#x201D; the item and replace it after running <code>Q</code> but that means that there is an &#x201C;extra space&#x201D; where the item resides while <code>Q</code> runs. One of the nice things about CPS is that the whole state is recorded in the stack and pending expression (not counting modifications to the dictionary.)</p>
<h3 id="crosslinks-26">Crosslinks</h3>
<p><a href="#dipd">dipd</a> <a href="#dipdd">dipdd</a> <a href="#dupdip">dupdip</a> <a href="#dupdipd">dupdipd</a> <a href="#infra">infra</a></p>
<hr />
<h2 id="dipd">dipd</h2>
<p>Combinator</p>
<p>Like <a href="#dip">dip</a> but expects two items.</p>
<pre><code> ... y x [Q] . dipd
-------------------------
... . Q y x</code></pre>
<h3 id="discussion-25">Discussion</h3>
<p>See <a href="#dip">dip</a>.</p>
<h3 id="crosslinks-27">Crosslinks</h3>
<p><a href="#dip">dip</a> <a href="#dipdd">dipdd</a> <a href="#dupdip">dupdip</a> <a href="#dupdipd">dupdipd</a> <a href="#infra">infra</a></p>
<hr />
<h2 id="dipdd">dipdd</h2>
<p>Combinator</p>
<p>Like <a href="#dip">dip</a> but expects three items. :</p>
<pre><code> ... z y x [Q] . dip
-----------------------------
... . Q z y x</code></pre>
<h3 id="discussion-26">Discussion</h3>
<p>See <a href="#dip">dip</a>.</p>
<h3 id="crosslinks-28">Crosslinks</h3>
<p><a href="#dip">dip</a> <a href="#dipd">dipd</a> <a href="#dupdip">dupdip</a> <a href="#dupdipd">dupdipd</a> <a href="#infra">infra</a></p>
<hr />
<h2 id="disenstacken">disenstacken</h2>
<p>Function</p>
<p>The <code>disenstacken</code> function expects a list on top of the stack and makes that the stack discarding the rest of the stack.</p>
<pre><code> 1 2 3 [4 5 6] disenstacken
--------------------------------
6 5 4</code></pre>
<h3 id="definition-24">Definition</h3>
<blockquote>
<p>[<a href="#clear">clear</a>] <a href="#dip">dip</a> <a href="#reverse">reverse</a> <a href="#unstack">unstack</a></p>
</blockquote>
<h3 id="discussion-27">Discussion</h3>
<p>Note that the order of the list is not changed, it just looks that way because the stack is printed with the top on the right while lists are printed with the top or head on the left.</p>
<h3 id="crosslinks-29">Crosslinks</h3>
<p><a href="#enstacken">enstacken</a> <a href="#stack">stack</a> <a href="#unstack">unstack</a></p>
<hr />
<h2 id="div">div</h2>
<p>See <a href="#floordiv">floordiv</a>.</p>
<hr />
<h2 id="divmod">divmod</h2>
<p>Function</p>
<pre><code> x y divmod
------------------
q r
(x/y) (x%y)</code></pre>
<p>Invariant: <code>qy + r = x</code>.</p>
<h3 id="definition-25">Definition</h3>
<blockquote>
<p>[<a href="#floordiv">floordiv</a>] [<a href="#mod">mod</a>] <a href="#clop">clop</a></p>
</blockquote>
<hr />
<h2 id="down_to_zero">down_to_zero</h2>
<p>Function</p>
<p>Given a number greater than zero put all the Natural numbers (including zero) less than that onto the stack.</p>
<h3 id="example-2">Example</h3>
<pre><code> 3 down_to_zero
--------------------
3 2 1 0</code></pre>
<h3 id="definition-26">Definition</h3>
<blockquote>
<p>[0 &gt;] [<a href="#dup">dup</a> <a href="#section-12">&#x2013;</a>] <a href="#while">while</a></p>
</blockquote>
<h3 id="crosslinks-30">Crosslinks</h3>
<p><a href="#range">range</a></p>
<hr />
<h2 id="drop">drop</h2>
<p>Function</p>
<p>Expects an integer and a quote on the stack and returns the quote with n items removed off the top.</p>
<h3 id="example-3">Example</h3>
<pre><code> [a b c d] 2 drop
----------------------
[c d]</code></pre>
<h3 id="definition-27">Definition</h3>
<blockquote>
<p>[<a href="#rest">rest</a>] <a href="#times">times</a></p>
</blockquote>
<h3 id="crosslinks-31">Crosslinks</h3>
<p><a href="#take">take</a></p>
<hr />
<h2 id="dup">dup</h2>
<p>Basis Function</p>
<p>&#x201C;Dup&#x201D;licate the top item on the stack.</p>
<pre><code> a dup
-----------
a a</code></pre>
<h3 id="crosslinks-32">Crosslinks</h3>
<p><a href="#dupd">dupd</a> <a href="#dupdd">dupdd</a> <a href="#dupdip">dupdip</a> <a href="#dupdipd">dupdipd</a></p>
<hr />
<h2 id="dupd">dupd</h2>
<p>Function</p>
<p><a href="#dup">dup</a> the second item down on the stack.</p>
<pre><code> a b dupd
--------------
a a b</code></pre>
<h3 id="definition-28">Definition</h3>
<blockquote>
<p>[<a href="#dup">dup</a>] <a href="#dip">dip</a></p>
</blockquote>
<h3 id="crosslinks-33">Crosslinks</h3>
<p><a href="#dup">dup</a> <a href="#dupdd">dupdd</a> <a href="#dupdip">dupdip</a> <a href="#dupdipd">dupdipd</a></p>
<hr />
<h2 id="dupdd">dupdd</h2>
<p>Function</p>
<p><a href="#dup">dup</a> the third item down on the stack.</p>
<pre><code> a b c dupdd
-----------------
a a b c</code></pre>
<h3 id="definition-29">Definition</h3>
<blockquote>
<p>[<a href="#dup">dup</a>] <a href="#dipd">dipd</a></p>
</blockquote>
<h3 id="crosslinks-34">Crosslinks</h3>
<p><a href="#dup">dup</a> <a href="#dupd">dupd</a> <a href="#dupdip">dupdip</a> <a href="#dupdipd">dupdipd</a></p>
<hr />
<h2 id="dupdip">dupdip</h2>
<p>Combinator</p>
<p>Apply a function <code>F</code> and <a href="#dup">dup</a> the item under it on the stack.</p>
<pre><code> a [F] dupdip
------------------
a F a</code></pre>
<h3 id="definition-30">Definition</h3>
<blockquote>
<p><a href="#dupd">dupd</a> <a href="#dip">dip</a></p>
</blockquote>
<h3 id="derivation-2">Derivation</h3>
<pre><code>a [F] dupdip
a [F] dupd dip
a [F] [dup] dip dip
a dup [F] dip
a a [F] dip
a F a</code></pre>
<h3 id="discussion-28">Discussion</h3>
<p>A very common and useful combinator.</p>
<h3 id="crosslinks-35">Crosslinks</h3>
<p><a href="#dupdipd">dupdipd</a></p>
<hr />
<h2 id="dupdipd">dupdipd</h2>
<p>Combinator</p>
<p>Run a copy of program <code>F</code> under the next item down on the stack.</p>
<pre><code> a [F] dupdipd
-------------------
F a [F]</code></pre>
<h3 id="definition-31">Definition</h3>
<blockquote>
<p><a href="#dup">dup</a> <a href="#dipd">dipd</a></p>
</blockquote>
<h3 id="crosslinks-36">Crosslinks</h3>
<p><a href="#dupdip">dupdip</a></p>
<hr />
<h2 id="enstacken">enstacken</h2>
<p>Function</p>
<p>Put the stack onto the stack replacing the contents of the stack.</p>
<pre><code> ... a b c enstacken
-------------------------
[c b a ...]</code></pre>
<h3 id="definition-32">Definition</h3>
<blockquote>
<p><a href="#stack">stack</a> [<a href="#clear">clear</a>] <a href="#dip">dip</a></p>
</blockquote>
<h3 id="discussion-29">Discussion</h3>
<p>This is a destructive version of <a href="#stack">stack</a>. See the note under <a href="#disenstacken">disenstacken</a> about the apparent but illusory reversal of the stack.</p>
<h3 id="crosslinks-37">Crosslinks</h3>
<p><a href="#stack">stack</a> [unstack] <a href="#disenstacken">disenstacken</a></p>
<hr />
<h2 id="eq">eq</h2>
<p>Basis Function</p>
<p>Compare the two items on the top of the stack for equality and replace them with a Boolean value.</p>
<pre><code> a b eq
-------------
Boolean</code></pre>
<h3 id="discussion-30">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-38">Crosslinks</h3>
<p><a href="#cmp">cmp</a> <a href="#ge">ge</a> <a href="#gt">gt</a> <a href="#le">le</a> <a href="#lt">lt</a> <a href="#ne">ne</a></p>
<hr />
<h2 id="first">first</h2>
<p>Basis Function Combinator</p>
<pre><code>([a1 ...1] -- a1)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-33">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-3">Derivation</h3>
<p>if not basis.</p>
<h3 id="source">Source</h3>
<p>if basis</p>
<h3 id="discussion-31">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-39">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="first_two">first_two</h2>
<p>Basis Function Combinator</p>
<pre><code>([a1 a2 ...1] -- a1 a2)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-34">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-4">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-1">Source</h3>
<p>if basis</p>
<h3 id="discussion-32">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-40">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="flatten">flatten</h2>
<p>Basis Function Combinator</p>
<p>&lt;{} [concat] step</p>
<p>Gentzen diagram.</p>
<h3 id="definition-35">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-5">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-2">Source</h3>
<p>if basis</p>
<h3 id="discussion-33">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-41">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="floor-1">floor</h2>
<p>Basis Function Combinator</p>
<p>Return the floor of x as an Integral.</p>
<p>This is the largest integer &lt;= x.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-36">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-6">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-3">Source</h3>
<p>if basis</p>
<h3 id="discussion-34">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-42">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="floordiv">floordiv</h2>
<p>Basis Function Combinator</p>
<p>Same as a // b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-37">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-7">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-4">Source</h3>
<p>if basis</p>
<h3 id="discussion-35">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-43">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="fork">fork</h2>
<p>Basis Function Combinator</p>
<p>[i] app2</p>
<p>Gentzen diagram.</p>
<h3 id="definition-38">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-8">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-5">Source</h3>
<p>if basis</p>
<h3 id="discussion-36">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-44">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="fourth">fourth</h2>
<p>Basis Function Combinator</p>
<pre><code>([a1 a2 a3 a4 ...1] -- a4)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-39">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-9">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-6">Source</h3>
<p>if basis</p>
<h3 id="discussion-37">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-45">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="gcd">gcd</h2>
<p>Basis Function Combinator</p>
<p>true [tuck mod dup 0 &gt;] loop pop</p>
<p>Gentzen diagram.</p>
<h3 id="definition-40">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-10">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-7">Source</h3>
<p>if basis</p>
<h3 id="discussion-38">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-46">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="gcd2">gcd2</h2>
<p>Basis Function Combinator</p>
<p>Compiled GCD function.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-41">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-11">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-8">Source</h3>
<p>if basis</p>
<h3 id="discussion-39">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-47">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="ge">ge</h2>
<p>Basis Function Combinator</p>
<p>Same as a &gt;= b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-42">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-12">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-9">Source</h3>
<p>if basis</p>
<h3 id="discussion-40">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-48">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="genrec">genrec</h2>
<p>Basis Function Combinator</p>
<p>General Recursion Combinator. :</p>
<pre><code>[if] [then] [rec1] [rec2] genrec
---------------------------------------------------------------------
[if] [then] [rec1 [[if] [then] [rec1] [rec2] genrec] rec2] ifte</code></pre>
<p>From "Recursion Theory and Joy" (j05cmp.html) by Manfred von Thun: "The genrec combinator takes four program parameters in addition to whatever data parameters it needs. Fourth from the top is an if-part, followed by a then-part. If the if-part yields true, then the then-part is executed and the combinator terminates. The other two parameters are the rec1-part and the rec2-part. If the if-part yields false, the rec1-part is executed. Following that the four program parameters and the combinator are again pushed onto the stack bundled up in a quoted form. Then the rec2-part is executed, where it will find the bundled form. Typically it will then execute the bundled form, either with i or with app2, or some other combinator."</p>
<p>The way to design one of these is to fix your base case [then] and the test [if], and then treat rec1 and rec2 as an else-part "sandwiching" a quotation of the whole function.</p>
<p>For example, given a (general recursive) function 'F': :</p>
<pre><code>F == [I] [T] [R1] [R2] genrec</code></pre>
<p>If the [I] if-part fails you must derive R1 and R2 from: :</p>
<pre><code>... R1 [F] R2</code></pre>
<p>Just set the stack arguments in front, and figure out what R1 and R2 have to do to apply the quoted [F] in the proper way. In effect, the genrec combinator turns into an ifte combinator with a quoted copy of the original definition in the else-part: :</p>
<pre><code>F == [I] [T] [R1] [R2] genrec
== [I] [T] [R1 [F] R2] ifte</code></pre>
<p>Primitive recursive functions are those where R2 == i. :</p>
<pre><code>P == [I] [T] [R] tailrec
== [I] [T] [R [P] i] ifte
== [I] [T] [R P] ifte</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-43">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-13">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-10">Source</h3>
<p>if basis</p>
<h3 id="discussion-41">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-49">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="getitem">getitem</h2>
<p>Basis Function Combinator</p>
<pre><code>getitem == drop first</code></pre>
<p>Expects an integer and a quote on the stack and returns the item at the nth position in the quote counting from 0. :</p>
<pre><code>[a b c d] 0 getitem
-------------------------
a</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-44">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-14">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-11">Source</h3>
<p>if basis</p>
<h3 id="discussion-42">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-50">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="grabn">grabN</h2>
<p>Basis Function Combinator</p>
<p>&lt;{} [cons] times</p>
<p>Gentzen diagram.</p>
<h3 id="definition-45">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-15">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-12">Source</h3>
<p>if basis</p>
<h3 id="discussion-43">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-51">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="grba">grba</h2>
<p>Basis Function Combinator</p>
<p>[stack popd] dip</p>
<p>Gentzen diagram.</p>
<h3 id="definition-46">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-16">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-13">Source</h3>
<p>if basis</p>
<h3 id="discussion-44">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-52">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="gt">gt</h2>
<p>Basis Function Combinator</p>
<p>Same as a &gt; b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-47">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-17">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-14">Source</h3>
<p>if basis</p>
<h3 id="discussion-45">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-53">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="help">help</h2>
<p>Basis Function Combinator</p>
<p>Accepts a quoted symbol on the top of the stack and prints its docs.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-48">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-18">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-15">Source</h3>
<p>if basis</p>
<h3 id="discussion-46">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-54">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="hypot">hypot</h2>
<p>Basis Function Combinator</p>
<p>[sqr] ii + sqrt</p>
<p>Gentzen diagram.</p>
<h3 id="definition-49">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-19">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-16">Source</h3>
<p>if basis</p>
<h3 id="discussion-47">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-55">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="i">i</h2>
<p>(Basis Combinator)</p>
<p>Append a quoted expression onto the pending expression.</p>
<pre><code> [Q] i
-----------
Q</code></pre>
<h3 id="source-17">Source</h3>
<pre><code>combo(i, [list(P)|S], S, Ei, Eo) :- append(P, Ei, Eo).</code></pre>
<h3 id="discussion-48">Discussion</h3>
<p>This is probably the fundamental combinator. You wind up using it in all kinds of places (for example, the <code>x</code> combinator can be defined as <code>dup i</code>.)</p>
<hr />
<h2 id="id">id</h2>
<p>Basis Function Combinator</p>
<p>The identity function.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-50">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-20">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-18">Source</h3>
<p>if basis</p>
<h3 id="discussion-49">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-56">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="ifte">ifte</h2>
<p>Basis Function Combinator</p>
<p>If-Then-Else Combinator :</p>
<pre><code>... [if] [then] [else] ifte
---------------------------------------------------
... [[else] [then]] [...] [if] infra select i
... [if] [then] [else] ifte
-------------------------------------------------------
... [else] [then] [...] [if] infra first choice i</code></pre>
<p>Has the effect of grabbing a copy of the stack on which to run the if-part using infra.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-51">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-21">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-19">Source</h3>
<p>if basis</p>
<h3 id="discussion-50">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-57">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="ii">ii</h2>
<p>Basis Function Combinator</p>
<pre><code>... a [Q] ii
------------------
... Q a Q</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-52">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-22">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-20">Source</h3>
<p>if basis</p>
<h3 id="discussion-51">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-58">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="infra">infra</h2>
<p>(Combinator)</p>
<p>Accept a quoted program and a list on the stack and run the program with the list as its stack. Does not affect the stack (below the list.)</p>
<pre><code> ... [a b c] [Q] infra
---------------------------
c b a Q [...] swaack</code></pre>
<h3 id="definition-53">Definition</h3>
<pre><code>swons swaack [i] dip swaack</code></pre>
<h3 id="discussion-52">Discussion</h3>
<p>This is one of the more useful combinators. It allows a quoted expression to serve as a stack for a program, effectively running it in a kind of &#x201C;pocket universe&#x201D;. If the list represents a datastructure then <code>infra</code> lets you work on its internal structure.</p>
<h3 id="crosslinks-59">Crosslinks</h3>
<p><a href="#swaack">swaack</a></p>
<hr />
<h2 id="infrst">infrst</h2>
<p>Basis Function Combinator</p>
<p>infra first</p>
<p>Gentzen diagram.</p>
<h3 id="definition-54">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-23">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-21">Source</h3>
<p>if basis</p>
<h3 id="discussion-53">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-60">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="inscribe">inscribe</h2>
<p>Basis Function Combinator</p>
<p>Create a new Joy function definition in the Joy dictionary. A definition is given as a quote with a name followed by a Joy expression. for example:</p>
<blockquote>
<p>[sqr dup mul] inscribe</p>
</blockquote>
<p>Gentzen diagram.</p>
<h3 id="definition-55">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-24">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-22">Source</h3>
<p>if basis</p>
<h3 id="discussion-54">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-61">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="le">le</h2>
<p>Basis Function Combinator</p>
<p>Same as a &lt;= b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-56">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-25">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-23">Source</h3>
<p>if basis</p>
<h3 id="discussion-55">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-62">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="loop">loop</h2>
<p>Basis Function Combinator</p>
<p>Basic loop combinator. :</p>
<pre><code>... True [Q] loop
-----------------------
... Q [Q] loop
... False [Q] loop
------------------------
...</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-57">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-26">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-24">Source</h3>
<p>if basis</p>
<h3 id="discussion-56">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-63">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="lshift">lshift</h2>
<p>Basis Function Combinator</p>
<p>Same as a &lt;&lt; b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-58">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-27">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-25">Source</h3>
<p>if basis</p>
<h3 id="discussion-57">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-64">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="lt">lt</h2>
<p>Basis Function Combinator</p>
<p>Same as a &lt; b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-59">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-28">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-26">Source</h3>
<p>if basis</p>
<h3 id="discussion-58">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-65">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="make_generator">make_generator</h2>
<p>Basis Function Combinator</p>
<p>[codireco] ccons</p>
<p>Gentzen diagram.</p>
<h3 id="definition-60">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-29">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-27">Source</h3>
<p>if basis</p>
<h3 id="discussion-59">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-66">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="map">map</h2>
<p>Basis Function Combinator</p>
<p>Run the quoted program on TOS on the items in the list under it, push a new list with the results in place of the program and original list.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-61">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-30">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-28">Source</h3>
<p>if basis</p>
<h3 id="discussion-60">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-67">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="max">max</h2>
<p>Basis Function Combinator</p>
<p>Given a list find the maximum.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-62">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-31">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-29">Source</h3>
<p>if basis</p>
<h3 id="discussion-61">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-68">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="min">min</h2>
<p>Basis Function Combinator</p>
<p>Given a list find the minimum.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-63">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-32">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-30">Source</h3>
<p>if basis</p>
<h3 id="discussion-62">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-69">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="mod">mod</h2>
<p>Basis Function Combinator</p>
<p>Same as a % b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-64">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-33">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-31">Source</h3>
<p>if basis</p>
<h3 id="discussion-63">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-70">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="modulus">modulus</h2>
<p>See <a href="#mod">mod</a>.</p>
<hr />
<h2 id="mul">mul</h2>
<p>Basis Function Combinator</p>
<p>Same as a * b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-65">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-34">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-32">Source</h3>
<p>if basis</p>
<h3 id="discussion-64">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-71">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="ne">ne</h2>
<p>Basis Function Combinator</p>
<p>Same as a != b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-66">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-35">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-33">Source</h3>
<p>if basis</p>
<h3 id="discussion-65">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-72">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="neg">neg</h2>
<p>Basis Function Combinator</p>
<p>Same as -a.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-67">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-36">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-34">Source</h3>
<p>if basis</p>
<h3 id="discussion-66">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-73">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="not">not</h2>
<p>Basis Function Combinator</p>
<p>Same as not a.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-68">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-37">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-35">Source</h3>
<p>if basis</p>
<h3 id="discussion-67">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-74">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="section-26">!-</h2>
<p>&#x201C;not negative&#x201D;</p>
<p>(Function, Boolean Predicate)</p>
<p>Integer on top of stack is replaced by Boolean value indicating whether it is non-negative.</p>
<pre><code> N !-
----------- N &lt; 0
false
N !-
---------- N &gt;= 0
true</code></pre>
<h3 id="definition-69">Definition</h3>
<pre><code>0 &gt;=</code></pre>
<hr />
<h2 id="nulco">nulco</h2>
<p>Basis Function Combinator</p>
<p>[nullary] cons</p>
<p>Gentzen diagram.</p>
<h3 id="definition-70">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-38">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-36">Source</h3>
<p>if basis</p>
<h3 id="discussion-68">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-75">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="nullary">nullary</h2>
<p>(Combinator)</p>
<p>Run a quoted program without using any stack values and leave the first item of the result on the stack.</p>
<pre><code> ... [P] nullary
---------------------
... A</code></pre>
<h3 id="definition-71">Definition</h3>
<pre><code>[stack] dip infra first</code></pre>
<h3 id="derivation-39">Derivation</h3>
<pre><code>... [P] nullary
... [P] [stack] dip infra first
... stack [P] infra first
... [...] [P] infra first
... [A ...] first
... A</code></pre>
<h3 id="discussion-69">Discussion</h3>
<p>A very useful function that runs any other quoted function and returns it&#x2019;s first result without disturbing the stack (under the quoted program.)</p>
<h3 id="crosslinks-76">Crosslinks</h3>
<p><a href="#unary">unary</a> <a href="#binary">binary</a> <a href="#ternary">ternary</a></p>
<hr />
<h2 id="of">of</h2>
<p>Basis Function Combinator</p>
<p>swap at</p>
<p>Gentzen diagram.</p>
<h3 id="definition-72">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-40">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-37">Source</h3>
<p>if basis</p>
<h3 id="discussion-70">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-77">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="or">or</h2>
<p>Basis Function Combinator</p>
<p>Same as a | b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-73">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-41">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-38">Source</h3>
<p>if basis</p>
<h3 id="discussion-71">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-78">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="over">over</h2>
<p>Basis Function Combinator</p>
<pre><code>(a2 a1 -- a2 a1 a2)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-74">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-42">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-39">Source</h3>
<p>if basis</p>
<h3 id="discussion-72">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-79">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="pam">pam</h2>
<p>Basis Function Combinator</p>
<p>[i] map</p>
<p>Gentzen diagram.</p>
<h3 id="definition-75">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-43">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-40">Source</h3>
<p>if basis</p>
<h3 id="discussion-73">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-80">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="pick">pick</h2>
<p>See <a href="#getitem">getitem</a>.</p>
<hr />
<h2 id="pm">pm</h2>
<p>Basis Function Combinator</p>
<p>Plus or minus :</p>
<pre><code>a b pm
-------------
a+b a-b</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-76">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-44">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-41">Source</h3>
<p>if basis</p>
<h3 id="discussion-74">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-81">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="pop">pop</h2>
<p>Basis Function Combinator</p>
<pre><code>(a1 --)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-77">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-45">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-42">Source</h3>
<p>if basis</p>
<h3 id="discussion-75">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-82">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="popd">popd</h2>
<p>Basis Function Combinator</p>
<pre><code>(a2 a1 -- a1)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-78">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-46">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-43">Source</h3>
<p>if basis</p>
<h3 id="discussion-76">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-83">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="popdd">popdd</h2>
<p>Basis Function Combinator</p>
<pre><code>(a3 a2 a1 -- a2 a1)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-79">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-47">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-44">Source</h3>
<p>if basis</p>
<h3 id="discussion-77">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-84">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="popop">popop</h2>
<p>Basis Function Combinator</p>
<pre><code>(a2 a1 --)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-80">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-48">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-45">Source</h3>
<p>if basis</p>
<h3 id="discussion-78">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-85">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="popopd">popopd</h2>
<p>Basis Function Combinator</p>
<pre><code>(a3 a2 a1 -- a1)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-81">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-49">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-46">Source</h3>
<p>if basis</p>
<h3 id="discussion-79">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-86">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="popopdd">popopdd</h2>
<p>Basis Function Combinator</p>
<pre><code>(a4 a3 a2 a1 -- a2 a1)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-82">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-50">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-47">Source</h3>
<p>if basis</p>
<h3 id="discussion-80">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-87">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="popopop">popopop</h2>
<p>Basis Function Combinator</p>
<p>pop popop</p>
<p>Gentzen diagram.</p>
<h3 id="definition-83">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-51">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-48">Source</h3>
<p>if basis</p>
<h3 id="discussion-81">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-88">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="pow">pow</h2>
<p>Basis Function Combinator</p>
<p>Same as a ** b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-84">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-52">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-49">Source</h3>
<p>if basis</p>
<h3 id="discussion-82">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-89">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="pred">pred</h2>
<p>Basis Function Combinator</p>
<p>Decrement TOS.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-85">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-53">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-50">Source</h3>
<p>if basis</p>
<h3 id="discussion-83">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-90">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="primrec">primrec</h2>
<p>Basis Function Combinator</p>
<p>From the "Overview of the language JOY":</p>
<p>&gt; The primrec combinator expects two quoted programs in addition to a data parameter. For an integer data parameter it works like this: If the data parameter is zero, then the first quotation has to produce the value to be returned. If the data parameter is positive then the second has to combine the data parameter with the result of applying the function to its predecessor.:</p>
<pre><code>5 [1] [*] primrec</code></pre>
<p>&gt; Then primrec tests whether the top element on the stack (initially the 5) is equal to zero. If it is, it pops it off and executes one of the quotations, the [1] which leaves 1 on the stack as the result. Otherwise it pushes a decremented copy of the top element and recurses. On the way back from the recursion it uses the other quotation, [*], to multiply what is now a factorial on top of the stack by the second element on the stack.:</p>
<pre><code>n [Base] [Recur] primrec
0 [Base] [Recur] primrec
------------------------------
Base
n [Base] [Recur] primrec
------------------------------------------ n &gt; 0
n (n-1) [Base] [Recur] primrec Recur</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-86">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-54">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-51">Source</h3>
<p>if basis</p>
<h3 id="discussion-84">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-91">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="product">product</h2>
<p>Basis Function Combinator</p>
<p>1 swap [*] step</p>
<p>Gentzen diagram.</p>
<h3 id="definition-87">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-55">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-52">Source</h3>
<p>if basis</p>
<h3 id="discussion-85">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-92">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="quoted">quoted</h2>
<p>Basis Function Combinator</p>
<p>[unit] dip</p>
<p>Gentzen diagram.</p>
<h3 id="definition-88">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-56">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-53">Source</h3>
<p>if basis</p>
<h3 id="discussion-86">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-93">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="range">range</h2>
<p>Basis Function Combinator</p>
<p>[0 &lt;=] [1 - dup] anamorphism</p>
<p>Gentzen diagram.</p>
<h3 id="definition-89">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-57">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-54">Source</h3>
<p>if basis</p>
<h3 id="discussion-87">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-94">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="range_to_zero">range_to_zero</h2>
<p>Basis Function Combinator</p>
<p>unit [down_to_zero] infra</p>
<p>Gentzen diagram.</p>
<h3 id="definition-90">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-58">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-55">Source</h3>
<p>if basis</p>
<h3 id="discussion-88">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-95">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="reco">reco</h2>
<p>Basis Function Combinator</p>
<p>rest cons</p>
<p>Gentzen diagram.</p>
<h3 id="definition-91">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-59">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-56">Source</h3>
<p>if basis</p>
<h3 id="discussion-89">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-96">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="rem">rem</h2>
<p>See <a href="#mod">mod</a>.</p>
<hr />
<h2 id="remainder">remainder</h2>
<p>See <a href="#mod">mod</a>.</p>
<hr />
<h2 id="remove">remove</h2>
<p>Basis Function Combinator</p>
<p>Expects an item on the stack and a quote under it and removes that item from the the quote. The item is only removed once. If the list is empty or the item isn't in the list then the list is unchanged. :</p>
<pre><code>[1 2 3 1] 1 remove
------------------------
[2 3 1]</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-92">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-60">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-57">Source</h3>
<p>if basis</p>
<h3 id="discussion-90">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-97">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="rest">rest</h2>
<p>Basis Function Combinator</p>
<pre><code>([a1 ...0] -- [...0])</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-93">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-61">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-58">Source</h3>
<p>if basis</p>
<h3 id="discussion-91">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-98">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="reverse">reverse</h2>
<p>Basis Function Combinator</p>
<p>Reverse the list on the top of the stack. :</p>
<pre><code>reverse == [] swap shunt</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-94">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-62">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-59">Source</h3>
<p>if basis</p>
<h3 id="discussion-92">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-99">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="rolldown">rolldown</h2>
<p>Basis Function Combinator</p>
<pre><code>(a1 a2 a3 -- a2 a3 a1)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-95">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-63">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-60">Source</h3>
<p>if basis</p>
<h3 id="discussion-93">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-100">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="rollup">rollup</h2>
<p>Basis Function Combinator</p>
<pre><code>(a1 a2 a3 -- a3 a1 a2)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-96">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-64">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-61">Source</h3>
<p>if basis</p>
<h3 id="discussion-94">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-101">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="roll">roll&gt;</h2>
<p>See <a href="#rollup">rollup</a>.</p>
<hr />
<h2 id="roll-1">roll&lt;</h2>
<p>See <a href="#rolldown">rolldown</a>.</p>
<hr />
<h2 id="round">round</h2>
<p>Basis Function Combinator</p>
<p>Round a number to a given precision in decimal digits.</p>
<p>The return value is an integer if ndigits is omitted or None. Otherwise the return value has the same type as the number. ndigits may be negative.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-97">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-65">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-62">Source</h3>
<p>if basis</p>
<h3 id="discussion-95">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-102">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="rrest">rrest</h2>
<p>Basis Function Combinator</p>
<pre><code>([a1 a2 ...1] -- [...1])</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-98">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-66">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-63">Source</h3>
<p>if basis</p>
<h3 id="discussion-96">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-103">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="rshift">rshift</h2>
<p>Basis Function Combinator</p>
<p>Same as a &gt;&gt; b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-99">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-67">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-64">Source</h3>
<p>if basis</p>
<h3 id="discussion-97">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-104">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="run">run</h2>
<p>Basis Function Combinator</p>
<p>&lt;{} infra</p>
<p>Gentzen diagram.</p>
<h3 id="definition-100">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-68">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-65">Source</h3>
<p>if basis</p>
<h3 id="discussion-98">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-105">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="second">second</h2>
<p>Basis Function Combinator</p>
<pre><code>([a1 a2 ...1] -- a2)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-101">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-69">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-66">Source</h3>
<p>if basis</p>
<h3 id="discussion-99">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-106">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="select">select</h2>
<p>Basis Function Combinator</p>
<p>Use a Boolean value to select one of two items from a sequence. :</p>
<pre><code>[A B] false select
------------------------
A
[A B] true select
-----------------------
B</code></pre>
<p>The sequence can contain more than two items but not fewer. Currently Python semantics are used to evaluate the "truthiness" of the Boolean value (so empty string, zero, etc. are counted as false, etc.)</p>
<p>Gentzen diagram.</p>
<h3 id="definition-102">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-70">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-67">Source</h3>
<p>if basis</p>
<h3 id="discussion-100">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-107">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="sharing">sharing</h2>
<p>Basis Function Combinator</p>
<p>Print redistribution information.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-103">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-71">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-68">Source</h3>
<p>if basis</p>
<h3 id="discussion-101">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-108">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="shift">shift</h2>
<p>Basis Function Combinator</p>
<p>uncons [swons] dip</p>
<p>Gentzen diagram.</p>
<h3 id="definition-104">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-72">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-69">Source</h3>
<p>if basis</p>
<h3 id="discussion-102">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-109">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="shunt">shunt</h2>
<p>Basis Function Combinator</p>
<p>Like concat but reverses the top list into the second. :</p>
<pre><code>shunt == [swons] step == reverse swap concat
[a b c] [d e f] shunt
---------------------------
[f e d a b c] </code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-105">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-73">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-70">Source</h3>
<p>if basis</p>
<h3 id="discussion-103">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-110">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="size">size</h2>
<p>Basis Function Combinator</p>
<p>[pop ++] step_zero</p>
<p>Gentzen diagram.</p>
<h3 id="definition-106">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-74">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-71">Source</h3>
<p>if basis</p>
<h3 id="discussion-104">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-111">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="sort">sort</h2>
<p>Basis Function Combinator</p>
<p>Given a list return it sorted.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-107">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-75">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-72">Source</h3>
<p>if basis</p>
<h3 id="discussion-105">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-112">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="spiral_next">spiral_next</h2>
<p>Basis Function Combinator</p>
<p>[[[abs] ii &lt;=] [[&lt;&gt;] [pop !-] ||] &amp;&amp;] [[!-] [[++]] [[--]] ifte dip] [[pop !-] [--] [++] ifte] ifte</p>
<p>Gentzen diagram.</p>
<h3 id="definition-108">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-76">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-73">Source</h3>
<p>if basis</p>
<h3 id="discussion-106">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-113">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="split_at">split_at</h2>
<p>Basis Function Combinator</p>
<p>[drop] [take] clop</p>
<p>Gentzen diagram.</p>
<h3 id="definition-109">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-77">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-74">Source</h3>
<p>if basis</p>
<h3 id="discussion-107">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-114">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="split_list">split_list</h2>
<p>Basis Function Combinator</p>
<p>[take reverse] [drop] clop</p>
<p>Gentzen diagram.</p>
<h3 id="definition-110">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-78">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-75">Source</h3>
<p>if basis</p>
<h3 id="discussion-108">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-115">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="sqr">sqr</h2>
<p>Basis Function Combinator</p>
<p>dup *</p>
<p>Gentzen diagram.</p>
<h3 id="definition-111">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-79">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-76">Source</h3>
<p>if basis</p>
<h3 id="discussion-109">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-116">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="sqrt">sqrt</h2>
<p>Basis Function Combinator</p>
<p>Return the square root of the number a. Negative numbers return complex roots.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-112">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-80">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-77">Source</h3>
<p>if basis</p>
<h3 id="discussion-110">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-117">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="stack">stack</h2>
<p>Basis Function Combinator</p>
<pre><code>(... -- ... [...])</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-113">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-81">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-78">Source</h3>
<p>if basis</p>
<h3 id="discussion-111">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-118">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="stackd">stackd</h2>
<p>Basis Function Combinator</p>
<p>[stack] dip</p>
<p>Gentzen diagram.</p>
<h3 id="definition-114">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-82">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-79">Source</h3>
<p>if basis</p>
<h3 id="discussion-112">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-119">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="step">step</h2>
<p>Basis Function Combinator</p>
<p>Run a quoted program on each item in a sequence. :</p>
<pre><code>... [] [Q] . step
-----------------------
... .
... [a] [Q] . step
------------------------
... a . Q
... [a b c] [Q] . step
----------------------------------------
... a . Q [b c] [Q] step</code></pre>
<p>The step combinator executes the quotation on each member of the list on top of the stack.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-115">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-83">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-80">Source</h3>
<p>if basis</p>
<h3 id="discussion-113">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-120">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="step_zero">step_zero</h2>
<p>Basis Function Combinator</p>
<p>0 roll&gt; step</p>
<p>Gentzen diagram.</p>
<h3 id="definition-116">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-84">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-81">Source</h3>
<p>if basis</p>
<h3 id="discussion-114">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-121">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="stuncons">stuncons</h2>
<p>Basis Function Combinator</p>
<pre><code>(... a1 -- ... a1 a1 [...])</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-117">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-85">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-82">Source</h3>
<p>if basis</p>
<h3 id="discussion-115">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-122">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="stununcons">stununcons</h2>
<p>Basis Function Combinator</p>
<pre><code>(... a2 a1 -- ... a2 a1 a1 a2 [...])</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-118">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-86">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-83">Source</h3>
<p>if basis</p>
<h3 id="discussion-116">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-123">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="sub">sub</h2>
<p>Basis Function Combinator</p>
<p>Same as a - b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-119">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-87">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-84">Source</h3>
<p>if basis</p>
<h3 id="discussion-117">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-124">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="succ">succ</h2>
<p>Basis Function Combinator</p>
<p>Increment TOS.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-120">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-88">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-85">Source</h3>
<p>if basis</p>
<h3 id="discussion-118">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-125">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="sum">sum</h2>
<p>Basis Function Combinator</p>
<p>Given a quoted sequence of numbers return the sum. :</p>
<pre><code>sum == 0 swap [+] step</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-121">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-89">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-86">Source</h3>
<p>if basis</p>
<h3 id="discussion-119">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-126">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="swaack">swaack</h2>
<p>Basis Function Combinator</p>
<pre><code>([...1] -- [...0])</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-122">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-90">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-87">Source</h3>
<p>if basis</p>
<h3 id="discussion-120">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-127">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="swap">swap</h2>
<p>Basis Function Combinator</p>
<pre><code>(a1 a2 -- a2 a1)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-123">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-91">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-88">Source</h3>
<p>if basis</p>
<h3 id="discussion-121">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-128">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="swapd">swapd</h2>
<p>Basis Function Combinator</p>
<p>[swap] dip</p>
<p>Gentzen diagram.</p>
<h3 id="definition-124">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-92">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-89">Source</h3>
<p>if basis</p>
<h3 id="discussion-122">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-129">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="swoncat">swoncat</h2>
<p>Basis Function Combinator</p>
<p>swap concat</p>
<p>Gentzen diagram.</p>
<h3 id="definition-125">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-93">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-90">Source</h3>
<p>if basis</p>
<h3 id="discussion-123">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-130">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="swons">swons</h2>
<p>Basis Function Combinator</p>
<pre><code>([...1] a1 -- [a1 ...1])</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-126">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-94">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-91">Source</h3>
<p>if basis</p>
<h3 id="discussion-124">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-131">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="tailrec">tailrec</h2>
<p>Basis Function Combinator</p>
<p>[i] genrec</p>
<p>Gentzen diagram.</p>
<h3 id="definition-127">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-95">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-92">Source</h3>
<p>if basis</p>
<h3 id="discussion-125">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-132">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="take">take</h2>
<p>Basis Function Combinator</p>
<p>Expects an integer and a quote on the stack and returns the quote with just the top n items in reverse order (because that's easier and you can use reverse if needed.) :</p>
<pre><code>[a b c d] 2 take
----------------------
[b a]</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-128">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-96">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-93">Source</h3>
<p>if basis</p>
<h3 id="discussion-126">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-133">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="ternary">ternary</h2>
<p>(Combinator)</p>
<p>Run a quoted program using exactly three stack values and leave the first item of the result on the stack.</p>
<pre><code> ... z y x [P] unary
-------------------------
... A</code></pre>
<h3 id="definition-129">Definition</h3>
<pre><code>binary popd</code></pre>
<h3 id="discussion-127">Discussion</h3>
<p>Runs any other quoted function and returns its first result while consuming exactly three items from the stack.</p>
<h3 id="crosslinks-134">Crosslinks</h3>
<p><a href="#binary">binary</a> <a href="#nullary">nullary</a> <a href="#unary">unary</a></p>
<hr />
<h2 id="third">third</h2>
<p>Basis Function Combinator</p>
<pre><code>([a1 a2 a3 ...1] -- a3)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-130">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-97">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-94">Source</h3>
<p>if basis</p>
<h3 id="discussion-128">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-135">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="times">times</h2>
<p>Basis Function Combinator</p>
<p>times == [-- dip] cons [swap] infra [0 &gt;] swap while pop :</p>
<pre><code>... n [Q] . times
--------------------- w/ n &lt;= 0
... .
... 1 [Q] . times
-----------------------
... . Q
... n [Q] . times
------------------------------------- w/ n &gt; 1
... . Q (n - 1) [Q] times</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-131">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-98">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-95">Source</h3>
<p>if basis</p>
<h3 id="discussion-129">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-136">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="truthy">truthy</h2>
<p>See <a href="#bool">bool</a>.</p>
<hr />
<h2 id="tuck">tuck</h2>
<p>Basis Function Combinator</p>
<pre><code>(a2 a1 -- a1 a2 a1)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-132">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-99">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-96">Source</h3>
<p>if basis</p>
<h3 id="discussion-130">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-137">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="unary">unary</h2>
<p>(Combinator)</p>
<p>Run a quoted program using exactly one stack value and leave the first item of the result on the stack.</p>
<pre><code> ... x [P] unary
---------------------
... A</code></pre>
<h3 id="definition-133">Definition</h3>
<pre><code>nullary popd</code></pre>
<h3 id="discussion-131">Discussion</h3>
<p>Runs any other quoted function and returns its first result while consuming exactly one item from the stack.</p>
<h3 id="crosslinks-138">Crosslinks</h3>
<p><a href="#binary">binary</a> <a href="#nullary">nullary</a> <a href="#ternary">ternary</a></p>
<hr />
<h2 id="uncons">uncons</h2>
<p>(Basis Function)</p>
<p>Removes an item from a list and leaves it on the stack under the rest of the list. You cannot <code>uncons</code> an item from an empty list.</p>
<pre><code> [A ...] uncons
--------------------
A [...]</code></pre>
<h3 id="source-97">Source</h3>
<pre><code>func(uncons, Si, So) :- func(cons, So, Si).</code></pre>
<h3 id="discussion-132">Discussion</h3>
<p>This is the inverse of <code>cons</code>.</p>
<h3 id="crosslinks-139">Crosslinks</h3>
<p><a href="#cons">cons</a></p>
<hr />
<h2 id="unique">unique</h2>
<p>Basis Function Combinator</p>
<p>Given a list remove duplicate items.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-134">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-100">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-98">Source</h3>
<p>if basis</p>
<h3 id="discussion-133">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-140">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="unit">unit</h2>
<p>Basis Function Combinator</p>
<pre><code>(a1 -- [a1 ])</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-135">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-101">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-99">Source</h3>
<p>if basis</p>
<h3 id="discussion-134">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-141">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="unquoted">unquoted</h2>
<p>Basis Function Combinator</p>
<p>[i] dip</p>
<p>Gentzen diagram.</p>
<h3 id="definition-136">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-102">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-100">Source</h3>
<p>if basis</p>
<h3 id="discussion-135">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-142">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="unswons">unswons</h2>
<p>Basis Function Combinator</p>
<pre><code>([a1 ...1] -- [...1] a1)</code></pre>
<p>Gentzen diagram.</p>
<h3 id="definition-137">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-103">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-101">Source</h3>
<p>if basis</p>
<h3 id="discussion-136">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-143">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="void">void</h2>
<p>Basis Function Combinator</p>
<p>True if the form on TOS is void otherwise False.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-138">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-104">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-102">Source</h3>
<p>if basis</p>
<h3 id="discussion-137">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-144">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="warranty">warranty</h2>
<p>Basis Function Combinator</p>
<p>Print warranty information.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-139">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-105">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-103">Source</h3>
<p>if basis</p>
<h3 id="discussion-138">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-145">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="while">while</h2>
<p>Basis Function Combinator</p>
<p>swap nulco dupdipd concat loop</p>
<p>Gentzen diagram.</p>
<h3 id="definition-140">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-106">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-104">Source</h3>
<p>if basis</p>
<h3 id="discussion-139">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-146">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="words">words</h2>
<p>Basis Function Combinator</p>
<p>Print all the words in alphabetical order.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-141">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-107">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-105">Source</h3>
<p>if basis</p>
<h3 id="discussion-140">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-147">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="x">x</h2>
<p>(Combinator)</p>
<pre><code> [F] x
-----------
[F] F</code></pre>
<h3 id="definition-142">Definition</h3>
<pre><code>dup i</code></pre>
<h3 id="discussion-141">Discussion</h3>
<p>The <code>x</code> combinator &#x2026;</p>
<hr />
<h2 id="xor">xor</h2>
<p>Basis Function Combinator</p>
<p>Same as a ^ b.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-143">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-108">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-106">Source</h3>
<p>if basis</p>
<h3 id="discussion-142">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-148">Crosslinks</h3>
<p>Lorem ipsum.</p>
<hr />
<h2 id="zip">zip</h2>
<p>Basis Function Combinator</p>
<p>Replace the two lists on the top of the stack with a list of the pairs from each list. The smallest list sets the length of the result list.</p>
<p>Gentzen diagram.</p>
<h3 id="definition-144">Definition</h3>
<p>if not basis.</p>
<h3 id="derivation-109">Derivation</h3>
<p>if not basis.</p>
<h3 id="source-107">Source</h3>
<p>if basis</p>
<h3 id="discussion-143">Discussion</h3>
<p>Lorem ipsum.</p>
<h3 id="crosslinks-149">Crosslinks</h3>
<p>Lorem ipsum.</p>
</body>
</html>