Strand notation: Difference between revisions

Jump to navigation Jump to search
10 bytes added ,  09:07, 29 October 2019
m
Text replacement - "</code>" to "</source>"
Miraheze>Adám Brudzewsky
m (Text replacement - "<code>" to "<source lang=apl inline>")
Miraheze>Adám Brudzewsky
m (Text replacement - "</code>" to "</source>")
Line 7: Line 7:
* In [[J]] stranding is a part of token formation rather than execution. Only plain numbers are stranded.
* In [[J]] stranding is a part of token formation rather than execution. Only plain numbers are stranded.


An example in which stranding interferes with the most obvious way of writing a program is shown below. Consider applying the function <source lang=apl inline>f</code> to <source lang=apl inline>0.8</code> three times using the [[Power operator]]:
An example in which stranding interferes with the most obvious way of writing a program is shown below. Consider applying the function <source lang=apl inline>f</source> to <source lang=apl inline>0.8</source> three times using the [[Power operator]]:
<pre class=apl>
<pre class=apl>
f⍣3 0.8
f⍣3 0.8
</pre>
</pre>
In a language which strands before function application, this expression is equivalent to the derived function <source lang=apl inline>f⍣(3,0.8)</code>. Not what was intended! The two numbers must be separated somehow, for instance with parentheses or a [[tack function]].
In a language which strands before function application, this expression is equivalent to the derived function <source lang=apl inline>f⍣(3,0.8)</source>. Not what was intended! The two numbers must be separated somehow, for instance with parentheses or a [[tack function]].
<pre class=apl>
<pre class=apl>
(f⍣3)0.8
(f⍣3)0.8
f⍣3⊢0.8
f⍣3⊢0.8
</pre>
</pre>
For operators that take array operands, such as the [[Rank operator]], stranding before operator application can be beneficial. Without it, a function with two ranks such as <source lang=apl inline>⊥⍤0 1</code> would have to be written with parentheses <source lang=apl inline>⊥⍤(0 1)</code>.
For operators that take array operands, such as the [[Rank operator]], stranding before operator application can be beneficial. Without it, a function with two ranks such as <source lang=apl inline>⊥⍤0 1</source> would have to be written with parentheses <source lang=apl inline>⊥⍤(0 1)</source>.

Navigation menu