OSDN Git Service

Bleah.
[joypy/Thun.git] / docs / sphinx_docs / _build / html / notebooks / The_Four_Operations.html
index 98b9e11..b2ae3a1 100644 (file)
@@ -4,15 +4,15 @@
 <html>
   <head>
     <meta 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 id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
+    <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>
-    <script src="../_static/language_data.js"></script>
-    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></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" />
@@ -33,7 +33,7 @@
 
           <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>
@@ -43,7 +43,7 @@ fundamental patterns of combination:</p>
 <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>
@@ -52,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>
@@ -94,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
@@ -116,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>
@@ -169,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
@@ -192,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
@@ -202,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>
@@ -226,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>
@@ -258,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>
@@ -267,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>
@@ -282,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
@@ -313,10 +313,10 @@ 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>
@@ -353,6 +353,7 @@ evaluation, yeah?)</p>
 <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>
@@ -379,7 +380,7 @@ evaluation, yeah?)</p>
   <h3 id="searchlabel">Quick search</h3>
     <div class="searchformwrapper">
     <form class="search" action="../search.html" method="get">
-      <input type="text" name="q" aria-labelledby="searchlabel" />
+      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
       <input type="submit" value="Go" />
     </form>
     </div>
@@ -403,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> 3.0.2.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
     </div>
 
   </body>