Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is just an initial stab at your questions, since nobody has replied so far:</p> <p>Adverbs have long left scope:</p> <pre><code>(2&amp;*~) &lt;-&gt; ((2&amp;*)~) </code></pre> <p>The dyadic case of the function returned by bond is <em>powered</em>:</p> <pre><code>(x m&amp;v y) &lt;-&gt; ((m&amp;v)^:x y) </code></pre> <p><code>2&amp;*</code> doubles its argument every time it's applied, so powered <code>2&amp;*</code> multiplies its argument by a power of <code>2</code>.</p> <p><code>(1&gt;.&lt;.@-:)^: 27</code> defines a verb (since <code>^:</code> is a conjunction), but does not run it. In the original phrase <code>foo^:a:</code> was the verb, and <code>27</code> the argument. When <code>a:</code> is the right argument of <code>^:</code> it just runs until it converges.</p> <p>Monadic <code>+:</code> doubles its argument, but the dyadic cases of <code>2&amp;*</code> and <code>+:</code> aren't related in any way, and can't be interchanged. Note that <code>double~</code> is the left side of a hook, which is always called dyadically.</p> <blockquote> <p>The only good thing is that the J verb odd has nothing to do with testing for an odd number.</p> </blockquote> <p>Actually, <code>2&amp;| y</code> is <code>1</code> if <code>y</code> is an odd integer and <code>0</code> if it is an even integer, so it is a test for odd numbers.</p> <p>Now, to try to explain what the algorithm is doing in plain English, let's look at it phrase by phrase, using <code>12 ethiop 27</code> as an example:</p> <pre><code>+/@(2&amp;|@] # (2&amp;*~ &lt;@#)) (1&gt;.&lt;.@-:)^:a: </code></pre> <p>is a hook. In hooks the right part is always a monad and the left part is always a dyad.</p> <pre><code>(1 &gt;. (&lt;. @ -:)) ^: a: </code></pre> <p>Monad <code>(&lt;. @ -:)</code> = <code>floor @ half</code>, <em>halves its argument and rounds down</em>, and then <code>1 &gt;. (&lt;. @ -:</code> returns the minimum of that and <code>1</code>. <code>^:a:</code> keeps going until convergence and makes a list of the result. Thus <code>(1 &gt;. (&lt;. @ -:)) ^: a: 27</code> is <code>27</code> halved repeatedly until it reaches <code>1</code>, yielding <code>27 13 6 3 1</code></p> <p>Now let's look at the left half of the hook. <code>(2&amp;|@] # (2&amp;*~ &lt;@#))</code> is a dyadic fork, with the arguments being the left argument to <code>ethiop</code> and the result of the right part of the aforementioned hook.</p> <p><code>2&amp;|@]</code> is <code>1</code> if its right argument is odd, <code>0</code> otherwise. For the argument <code>27 13 6 3 1</code> the result is <code>1 1 0 1 1</code></p> <p><code>(2&amp;*~ &lt;@#)</code> is a hook again. &lt;@# is applied monadically to <code>27 13 6 3 1</code>, and boxes the length, returning <code>(&lt;5)</code>. Then we get to <code>2&amp;*~</code>, which as we saw, is powered in the dyadic, so this is (after <code>~</code> switches the arguments) <code>+:^:(&lt;5) 12</code>.</p> <p><code>f^:m</code>, when <code>m</code> is boxed, does <code>f</code> <code>&lt;: &gt;m</code> times, yielding an <code>m</code>-length list of results (unless <code>m</code> is empty, in which case it runs until convergence). So this will yield <code>12 * 2 ^ i.5</code></p> <p>Then the middle part of the fork is simply <code>#</code>, which with a boolean left argument simply filters its right argument, in this case leaving 12 * those powers of 2 for which 27 is odd.</p> <pre><code> 1 1 0 1 1 # 12 24 48 96 192 12 24 96 192 </code></pre> <p>Finally <code>+/</code> is <code>sum</code></p> <pre><code> +/12 24 96 192 324 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload