OSDN Git Service

Bleah.
[joypy/Thun.git] / docs / sphinx_docs / _build / html / notebooks / The_Four_Operations.html
index 5e6b79e..b2ae3a1 100644 (file)
@@ -1,21 +1,22 @@
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
   <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <title>The Four Fundamental Operations of Definite Action &#8212; Thun 0.2.0 documentation</title>
-    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
-    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
-    <script type="text/javascript" src="../_static/documentation_options.js"></script>
-    <script type="text/javascript" src="../_static/jquery.js"></script>
-    <script type="text/javascript" src="../_static/underscore.js"></script>
-    <script type="text/javascript" src="../_static/doctools.js"></script>
-    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
+
+    <title>The Four Fundamental Operations of Definite Action &#8212; Thun 0.4.1 documentation</title>
+    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
+    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
+    <script src="../_static/jquery.js"></script>
+    <script src="../_static/underscore.js"></script>
+    <script src="../_static/doctools.js"></script>
     <link rel="index" title="Index" href="../genindex.html" />
     <link rel="search" title="Search" href="../search.html" />
+    <link rel="next" title="∂RE" href="Derivatives_of_Regular_Expressions.html" />
+    <link rel="prev" title="Categorical Programming" href="Categorical.html" />
    
   <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
   
     <div class="document">
       <div class="documentwrapper">
         <div class="bodywrapper">
+          
+
           <div class="body" role="main">
             
-  <div class="section" id="the-four-fundamental-operations-of-definite-action">
+  <section id="the-four-fundamental-operations-of-definite-action">
 <h1>The Four Fundamental Operations of Definite Action<a class="headerlink" href="#the-four-fundamental-operations-of-definite-action" title="Permalink to this headline">¶</a></h1>
 <p>All definite actions (computer program) can be defined by four
 fundamental patterns of combination:</p>
 <ol class="arabic simple">
-<li>Sequence</li>
-<li>Branch</li>
-<li>Loop</li>
-<li>Parallel</li>
+<li><p>Sequence</p></li>
+<li><p>Branch</p></li>
+<li><p>Loop</p></li>
+<li><p>Parallel</p></li>
 </ol>
-<div class="section" id="sequence">
+<section id="sequence">
 <h2>Sequence<a class="headerlink" href="#sequence" title="Permalink to this headline">¶</a></h2>
 <p>Do one thing after another. In joy this is represented by putting two
 symbols together, juxtaposition:</p>
@@ -49,8 +52,8 @@ symbols together, juxtaposition:</p>
 </div>
 <p>Operations have inputs and outputs. The outputs of <code class="docutils literal notranslate"><span class="pre">foo</span></code> must be
 compatible in “arity”, type, and shape with the inputs of <code class="docutils literal notranslate"><span class="pre">bar</span></code>.</p>
-</div>
-<div class="section" id="branch">
+</section>
+<section id="branch">
 <h2>Branch<a class="headerlink" href="#branch" title="Permalink to this headline">¶</a></h2>
 <p>Do one thing or another.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">boolean</span> <span class="p">[</span><span class="n">F</span><span class="p">]</span> <span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="n">branch</span>
@@ -91,7 +94,7 @@ outputs for <code class="docutils literal notranslate"><span class="pre">foo</sp
 <span class="n">foo</span> <span class="n">T</span> <span class="n">bar</span>
 </pre></div>
 </div>
-<div class="section" id="ifte">
+<section id="ifte">
 <h3><code class="docutils literal notranslate"><span class="pre">ifte</span></code><a class="headerlink" href="#ifte" title="Permalink to this headline">¶</a></h3>
 <p>Often it will be easier on the programmer to write branching code with
 the predicate specified in a quote. The <code class="docutils literal notranslate"><span class="pre">ifte</span></code> combinator provides
@@ -113,9 +116,9 @@ evaluate it. I reflect this in the structure of the stack effect comment
 of <code class="docutils literal notranslate"><span class="pre">branch</span></code>, it will only accept Boolean values, and in the definition
 of <code class="docutils literal notranslate"><span class="pre">ifte</span></code> above by including <code class="docutils literal notranslate"><span class="pre">not</span></code> in the quote, which also has the
 effect that the subject quotes are in the proper order for <code class="docutils literal notranslate"><span class="pre">branch</span></code>.)</p>
-</div>
-</div>
-<div class="section" id="loop">
+</section>
+</section>
+<section id="loop">
 <h2>Loop<a class="headerlink" href="#loop" title="Permalink to this headline">¶</a></h2>
 <p>Do one thing zero or more times.</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">boolean</span> <span class="p">[</span><span class="n">Q</span><span class="p">]</span> <span class="n">loop</span>
@@ -166,7 +169,7 @@ boolean flag for the next iteration:</p>
 <span class="n">G</span> <span class="n">G</span> <span class="n">G</span>
 </pre></div>
 </div>
-<div class="section" id="while">
+<section id="while">
 <h3><code class="docutils literal notranslate"><span class="pre">while</span></code><a class="headerlink" href="#while" title="Permalink to this headline">¶</a></h3>
 <p>Keep doing <code class="docutils literal notranslate"><span class="pre">B</span></code> <em>while</em> some predicate <code class="docutils literal notranslate"><span class="pre">P</span></code> is true. This is
 convenient as the predicate function is made nullary automatically and
@@ -189,9 +192,9 @@ flag for the next iteration:</p>
 <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="n">nullary</span> <span class="p">[</span><span class="n">B</span> <span class="p">[</span><span class="n">P</span><span class="p">]</span> <span class="n">nullary</span><span class="p">]</span> <span class="n">loop</span>
 </pre></div>
 </div>
-</div>
-</div>
-<div class="section" id="parallel">
+</section>
+</section>
+<section id="parallel">
 <h2>Parallel<a class="headerlink" href="#parallel" title="Permalink to this headline">¶</a></h2>
 <p>The <em>parallel</em> operation indicates that two (or more) functions <em>do not
 interfere</em> with each other and so can run in parallel. The main
@@ -199,10 +202,10 @@ difficulty in this sort of thing is orchestrating the recombining
 (“join” or “wait”) of the results of the functions after they finish.</p>
 <p>The current implementaions and the following definitions <em>are not
 actually parallel</em> (yet), but there is no reason they couldn’t be
-reimplemented in terms of e.g. Python threads. I am not concerned with
+reimplemented in terms of e.g. Python threads. I am not concerned with
 performance of the system just yet, only the elegance of the code it
 allows us to write.</p>
-<div class="section" id="cleave">
+<section id="cleave">
 <h3><code class="docutils literal notranslate"><span class="pre">cleave</span></code><a class="headerlink" href="#cleave" title="Permalink to this headline">¶</a></h3>
 <p>Joy has a few parallel combinators, the main one being <code class="docutils literal notranslate"><span class="pre">cleave</span></code>:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>               <span class="o">...</span> <span class="n">x</span> <span class="p">[</span><span class="n">A</span><span class="p">]</span> <span class="p">[</span><span class="n">B</span><span class="p">]</span> <span class="n">cleave</span>
@@ -223,8 +226,8 @@ Elliott’s “Compiling to Categories” paper, et. al.)</p>
 <p>Just a thought, if you <code class="docutils literal notranslate"><span class="pre">cleave</span></code> two jobs and one requires more time to
 finish than the other you’d like to be able to assign resources
 accordingly so that they both finish at the same time.</p>
-</div>
-<div class="section" id="apply-functions">
+</section>
+<section id="apply-functions">
 <h3>“Apply” Functions<a class="headerlink" href="#apply-functions" title="Permalink to this headline">¶</a></h3>
 <p>There are also <code class="docutils literal notranslate"><span class="pre">app2</span></code> and <code class="docutils literal notranslate"><span class="pre">app3</span></code> which run a single quote on more
 than one value:</p>
@@ -255,8 +258,8 @@ value.)</p>
      <span class="n">a</span> <span class="n">b</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="map">
+</section>
+<section id="map">
 <h3><code class="docutils literal notranslate"><span class="pre">map</span></code><a class="headerlink" href="#map" title="Permalink to this headline">¶</a></h3>
 <p>The common <code class="docutils literal notranslate"><span class="pre">map</span></code> function in Joy should also be though of as a
 <em>parallel</em> operator:</p>
@@ -264,9 +267,9 @@ value.)</p>
 </pre></div>
 </div>
 <p>There is no reason why the implementation of <code class="docutils literal notranslate"><span class="pre">map</span></code> couldn’t distribute
-the <code class="docutils literal notranslate"><span class="pre">Q</span></code> function over e.g. a pool of worker CPUs.</p>
-</div>
-<div class="section" id="pam">
+the <code class="docutils literal notranslate"><span class="pre">Q</span></code> function over e.g. a pool of worker CPUs.</p>
+</section>
+<section id="pam">
 <h3><code class="docutils literal notranslate"><span class="pre">pam</span></code><a class="headerlink" href="#pam" title="Permalink to this headline">¶</a></h3>
 <p>One of my favorite combinators, the <code class="docutils literal notranslate"><span class="pre">pam</span></code> combinator is just:</p>
 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pam</span> <span class="o">==</span> <span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="nb">map</span>
@@ -279,21 +282,21 @@ stack and combine their (first) outputs in a result list.</p>
    <span class="p">[</span> <span class="n">a</span>   <span class="n">b</span>   <span class="n">c</span>  <span class="o">...</span><span class="p">]</span>
 </pre></div>
 </div>
-</div>
-<div class="section" id="handling-other-kinds-of-join">
+</section>
+<section id="handling-other-kinds-of-join">
 <h3>Handling Other Kinds of Join<a class="headerlink" href="#handling-other-kinds-of-join" title="Permalink to this headline">¶</a></h3>
 <p>The <code class="docutils literal notranslate"><span class="pre">cleave</span></code> operators and others all have pretty brutal join
 semantics: everything works and we always wait for every
 sub-computation. We can imagine a few different potentially useful
 patterns of “joining” results from parallel combinators.</p>
-<div class="section" id="first-to-finish">
+<section id="first-to-finish">
 <h4>first-to-finish<a class="headerlink" href="#first-to-finish" title="Permalink to this headline">¶</a></h4>
 <p>Thinking about variations of <code class="docutils literal notranslate"><span class="pre">pam</span></code> there could be one that only
 returns the first result of the first-to-finish sub-program, or the
 stack could be replaced by its output stack.</p>
 <p>The other sub-programs would be cancelled.</p>
-</div>
-<div class="section" id="fulminators">
+</section>
+<section id="fulminators">
 <h4>“Fulminators”<a class="headerlink" href="#fulminators" title="Permalink to this headline">¶</a></h4>
 <p>Also known as “Futures” or “Promises” (by <em>everybody</em> else. “Fulinators”
 is what I was going to call them when I was thinking about implementing
@@ -310,70 +313,87 @@ with “asyncronous” … events?</p>
 sort of thing works perfectly in Joy code I’m not going to worry about
 it. (And I think the Categories can deal with it anyhow? Incremental
 evaluation, yeah?)</p>
-</div>
-</div>
-</div>
-</div>
+</section>
+</section>
+</section>
+</section>
 
 
           </div>
+          
         </div>
       </div>
       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
         <div class="sphinxsidebarwrapper">
-  <h3><a href="../index.html">Table Of Contents</a></h3>
-  <ul>
-<li><a class="reference internal" href="#">The Four Fundamental Operations of Definite Action</a><ul>
-<li><a class="reference internal" href="#sequence">Sequence</a></li>
-<li><a class="reference internal" href="#branch">Branch</a><ul>
-<li><a class="reference internal" href="#ifte"><code class="docutils literal notranslate"><span class="pre">ifte</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#loop">Loop</a><ul>
-<li><a class="reference internal" href="#while"><code class="docutils literal notranslate"><span class="pre">while</span></code></a></li>
-</ul>
-</li>
-<li><a class="reference internal" href="#parallel">Parallel</a><ul>
-<li><a class="reference internal" href="#cleave"><code class="docutils literal notranslate"><span class="pre">cleave</span></code></a></li>
-<li><a class="reference internal" href="#apply-functions">“Apply” Functions</a></li>
-<li><a class="reference internal" href="#map"><code class="docutils literal notranslate"><span class="pre">map</span></code></a></li>
-<li><a class="reference internal" href="#pam"><code class="docutils literal notranslate"><span class="pre">pam</span></code></a></li>
-<li><a class="reference internal" href="#handling-other-kinds-of-join">Handling Other Kinds of Join</a><ul>
-<li><a class="reference internal" href="#first-to-finish">first-to-finish</a></li>
-<li><a class="reference internal" href="#fulminators">“Fulminators”</a></li>
-</ul>
-</li>
-</ul>
-</li>
+<h1 class="logo"><a href="../index.html">Thun</a></h1>
+
+
+
+
+
+
+
+
+<h3>Navigation</h3>
+<ul class="current">
+<li class="toctree-l1"><a class="reference internal" href="Intro.html">Thun: Joy in Python</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../joy.html">Joy Interpreter</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../stack.html">Stack or Quote or Sequence or List…</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../parser.html">Parsing Text into Joy Expressions</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../pretty.html">Tracing Joy Execution</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../library.html">Function Reference</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../lib.html">Functions Grouped by, er, Function with Examples</a></li>
+<li class="toctree-l1"><a class="reference internal" href="../types.html">Type Inference of Joy Expressions</a></li>
+<li class="toctree-l1 current"><a class="reference internal" href="index.html">Essays about Programming in Joy</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" href="Developing.html">Developing a Program in Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Quadratic.html">Quadratic formula</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Replacing.html">Replacing Functions in the Dictionary</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Recursion_Combinators.html">Recursion Combinators</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Ordered_Binary_Trees.html">Treating Trees I: Ordered Binary Trees</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Treestep.html">Treating Trees II: <code class="docutils literal notranslate"><span class="pre">treestep</span></code></a></li>
+<li class="toctree-l2"><a class="reference internal" href="Generator_Programs.html">Using <code class="docutils literal notranslate"><span class="pre">x</span></code> to Generate Values</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Newton-Raphson.html">Newton’s method</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Square_Spiral.html">Square Spiral Example Joy Code</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Zipper.html">Traversing Datastructures with Zippers</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Types.html">The Blissful Elegance of Typing Joy</a></li>
+<li class="toctree-l2"><a class="reference internal" href="TypeChecking.html">Type Checking</a></li>
+<li class="toctree-l2"><a class="reference internal" href="NoUpdates.html">No Updates</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Categorical.html">Categorical Programming</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" href="#">The Four Fundamental Operations of Definite Action</a></li>
+<li class="toctree-l2"><a class="reference internal" href="Derivatives_of_Regular_Expressions.html">∂RE</a></li>
 </ul>
 </li>
 </ul>
+
 <div class="relations">
 <h3>Related Topics</h3>
 <ul>
   <li><a href="../index.html">Documentation overview</a><ul>
+  <li><a href="index.html">Essays about Programming in Joy</a><ul>
+      <li>Previous: <a href="Categorical.html" title="previous chapter">Categorical Programming</a></li>
+      <li>Next: <a href="Derivatives_of_Regular_Expressions.html" title="next chapter">∂RE</a></li>
+  </ul></li>
   </ul></li>
 </ul>
 </div>
-  <div role="note" aria-label="source link">
-    <h3>This Page</h3>
-    <ul class="this-page-menu">
-      <li><a href="../_sources/notebooks/The_Four_Operations.rst.txt"
-            rel="nofollow">Show Source</a></li>
-    </ul>
-   </div>
 <div id="searchbox" style="display: none" role="search">
-  <h3>Quick search</h3>
+  <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
-      <input type="hidden" name="check_keywords" value="yes" />
-      <input type="hidden" name="area" value="default" />
     </form>
     </div>
 </div>
-<script type="text/javascript">$('#searchbox').show(0);</script>
+<script>$('#searchbox').show(0);</script>
+
+
+
+
+
+
+
+
         </div>
       </div>
       <div class="clearer"></div>
@@ -384,7 +404,7 @@ evaluation, yeah?)</p>
 </a>
 <br />
 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
-      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>