More work on Ref doc, & stuff.

This commit is contained in:
sforman
2023-10-08 17:58:22 -07:00
parent d833f1a3e9
commit eb665f2b50
8 changed files with 119 additions and 13 deletions
+4 -4
View File
@@ -206,7 +206,7 @@ expressions, e.g.:
------------------
[a ...]
</code></pre></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>Cons is a <a href="https://en.wikipedia.org/wiki/Cons#Lists">venerable old function from Lisp</a>.
Its inverse operation is [uncons].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#uncons" class="func_name">uncons</a></div><div class="backlinks"><h3>Used By</h3><a href="#d5856351bbc14599e687dac105150e8a919b21477f3c00386405228caac1e43a" class="func_name">app2</a> <a href="#ccons" class="func_name">ccons</a> <a href="#codi" class="func_name">codi</a> <a href="#grabN" class="func_name">grabN</a> <a href="#map" class="func_name">map</a> <a href="#nulco" class="func_name">nulco</a> <a href="#pow" class="func_name">pow</a> <a href="#reco" class="func_name">reco</a> <a href="#swons" class="func_name">swons</a> <a href="#unit" class="func_name">unit</a></div></div><hr><div><h2 id="dinfrirst" class="func_name">dinfrirst <a href="#dinfrirst" class="self_link"></a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Specialist function (that means I forgot what it does and why.)</p></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition"><a href="#dip">dip</a> <a href="#infrst">infrst</a></div></div><div class="backlinks"><h3>Used By</h3><a href="#nullary" class="func_name">nullary</a></div></div><hr><div><h2 id="dip" class="func_name">dip <a href="#dip" class="self_link"></a></h2><p><span class="kind">combinator</span> <span class="kind">built-in</span></p><div class="notes"><p>The <code>dip</code> combinator expects a quoted program on the stack and below it
Its inverse operation is [uncons].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#uncons" class="func_name">uncons</a></div><div class="backlinks"><h3>Used By</h3><a href="#d5856351bbc14599e687dac105150e8a919b21477f3c00386405228caac1e43a" class="func_name">app2</a> <a href="#ccons" class="func_name">ccons</a> <a href="#codi" class="func_name">codi</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#" class="func_name">dipddd</a> <a href="#grabN" class="func_name">grabN</a> <a href="#map" class="func_name">map</a> <a href="#nulco" class="func_name">nulco</a> <a href="#pow" class="func_name">pow</a> <a href="#reco" class="func_name">reco</a> <a href="#swons" class="func_name">swons</a> <a href="#unit" class="func_name">unit</a></div></div><hr><div><h2 id="dinfrirst" class="func_name">dinfrirst <a href="#dinfrirst" class="self_link"></a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Specialist function (that means I forgot what it does and why.)</p></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition"><a href="#dip">dip</a> <a href="#infrst">infrst</a></div></div><div class="backlinks"><h3>Used By</h3><a href="#nullary" class="func_name">nullary</a></div></div><hr><div><h2 id="dip" class="func_name">dip <a href="#dip" class="self_link"></a></h2><p><span class="kind">combinator</span> <span class="kind">built-in</span></p><div class="notes"><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
@@ -224,15 +224,15 @@ Continuation-Passing Style. The <code>dip</code> combinator could "set aside" t
item and replace it after running <code>Q</code> but that means that there is an
"extra space" 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></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dipd" class="func_name">dipd</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div><div class="backlinks"><h3>Used By</h3><a href="#anamorphism" class="func_name">anamorphism</a> <a href="#and" class="func_name">and</a> <a href="#d5856351bbc14599e687dac105150e8a919b21477f3c00386405228caac1e43a" class="func_name">app2</a> <a href="#b" class="func_name">b</a> <a href="#codi" class="func_name">codi</a> <a href="#dinfrirst" class="func_name">dinfrirst</a> <a href="#dipd" class="func_name">dipd</a> <a href="#dupd" class="func_name">dupd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#enstacken" class="func_name">enstacken</a> <a href="#grba" class="func_name">grba</a> <a href="#ii" class="func_name">ii</a> <a href="#infra" class="func_name">infra</a> <a href="#map" class="func_name">map</a> <a href="#or" class="func_name">or</a> <a href="#over" class="func_name">over</a> <a href="#popd" class="func_name">popd</a> <a href="#popopd" class="func_name">popopd</a> <a href="#quoted" class="func_name">quoted</a> <a href="#shift" class="func_name">shift</a> <a href="#b75cae41e7f9ba4ab72cc1c5ec83aa5313ea180fae61bc25370ce4e4b540c3c7" class="func_name">spiral_next</a> <a href="#stackd" class="func_name">stackd</a> <a href="#swapd" class="func_name">swapd</a> <a href="#unquoted" class="func_name">unquoted</a> <a href="#" class="func_name">unstack</a></div></div><hr><div><h2 id="dipd" class="func_name">dipd <a href="#dipd" class="self_link"></a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Like [dip] but expects two items.</p>
pending expression (not counting modifications to the dictionary.)</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dipd" class="func_name">dipd</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div><div class="backlinks"><h3>Used By</h3><a href="#anamorphism" class="func_name">anamorphism</a> <a href="#and" class="func_name">and</a> <a href="#d5856351bbc14599e687dac105150e8a919b21477f3c00386405228caac1e43a" class="func_name">app2</a> <a href="#b" class="func_name">b</a> <a href="#codi" class="func_name">codi</a> <a href="#dinfrirst" class="func_name">dinfrirst</a> <a href="#dipd" class="func_name">dipd</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupd" class="func_name">dupd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#enstacken" class="func_name">enstacken</a> <a href="#grba" class="func_name">grba</a> <a href="#ii" class="func_name">ii</a> <a href="#infra" class="func_name">infra</a> <a href="#map" class="func_name">map</a> <a href="#or" class="func_name">or</a> <a href="#over" class="func_name">over</a> <a href="#popd" class="func_name">popd</a> <a href="#popopd" class="func_name">popopd</a> <a href="#quoted" class="func_name">quoted</a> <a href="#shift" class="func_name">shift</a> <a href="#b75cae41e7f9ba4ab72cc1c5ec83aa5313ea180fae61bc25370ce4e4b540c3c7" class="func_name">spiral_next</a> <a href="#stackd" class="func_name">stackd</a> <a href="#swapd" class="func_name">swapd</a> <a href="#unquoted" class="func_name">unquoted</a> <a href="#" class="func_name">unstack</a></div></div><hr><div><h2 id="dipd" class="func_name">dipd <a href="#dipd" class="self_link"></a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Like [dip] but expects two items.</p>
<pre><code> ... y x [Q] . dipd
-------------------------
... . Q y x
</code></pre></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition">[<a href="#dip">dip</a>] <a href="#codi">codi</a></div></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>See [dip].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dip" class="func_name">dip</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div><div class="backlinks"><h3>Used By</h3><a href="#cmp" class="func_name">cmp</a> <a href="#dupdd" class="func_name">dupdd</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#ifte" class="func_name">ifte</a> <a href="#popdd" class="func_name">popdd</a> <a href="#popopdd" class="func_name">popopdd</a></div></div><hr><div><h2 id="dipdd" class="func_name">dipdd <a href="#dipdd" class="self_link"></a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Like [dip] but expects three items. :</p>
</code></pre></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition">[<a href="#dip">dip</a>] <a href="#codi">codi</a></div></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>See [dip].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dip" class="func_name">dip</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div><div class="backlinks"><h3>Used By</h3><a href="#cmp" class="func_name">cmp</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#" class="func_name">dipddd</a> <a href="#dupdd" class="func_name">dupdd</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#ifte" class="func_name">ifte</a> <a href="#popdd" class="func_name">popdd</a> <a href="#popopdd" class="func_name">popopdd</a></div></div><hr><div><h2 id="dipdd" class="func_name">dipdd <a href="#dipdd" class="self_link"></a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Like [dip] but expects three items. :</p>
<pre><code> ... z y x [Q] . dip
-----------------------------
... . Q z y x
</code></pre></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>See [dip].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dip" class="func_name">dip</a> <a href="#dipd" class="func_name">dipd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div></div><hr><div><h2 id="disenstacken" class="func_name">disenstacken <a href="#disenstacken" class="self_link"></a></h2><p></p><div class="notes"><p>The <code>disenstacken</code> function expects a list on top of the stack and makes
</code></pre></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition">[<a href="#dip">dip</a>] <a href="#cons">cons</a> <a href="#dipd">dipd</a></div></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>See [dip].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dip" class="func_name">dip</a> <a href="#dipd" class="func_name">dipd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div></div><hr><div><h2 id="disenstacken" class="func_name">disenstacken <a href="#disenstacken" class="self_link"></a></h2><p></p><div class="notes"><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
--------------------------------
+16
View File
@@ -0,0 +1,16 @@
<div class="discussion"><p>This works by building a little [while] program and running it:
1 3 [++] • [-- dip] cons [swap] infra [0 &gt;] swap while pop <br>
1 3 [++] [-- dip] • cons [swap] infra [0 &gt;] swap while pop <br>
1 3 [[++] -- dip] • [swap] infra [0 &gt;] swap while pop <br>
1 3 [[++] -- dip] [swap] • infra [0 &gt;] swap while pop
dip -- [++] • swap [3 1] swaack [0 &gt;] swap while pop <br>
dip [++] -- • [3 1] swaack [0 &gt;] swap while pop <br>
dip [++] -- [3 1] • swaack [0 &gt;] swap while pop <br>
1 3 [-- [++] dip] • [0 &gt;] swap while pop <br>
1 3 [-- [++] dip] [0 &gt;] • swap while pop
1 3 [0 &gt;] [-- [++] dip] • while pop
This is a common pattern in Joy. You accept some parameters from the
stack which typically include qouted programs and use them to build
another program which does the actual work. This is kind of like macros
in Lisp, or preprocessor directives in C.</p></div>