Strand notation: Difference between revisions

Jump to navigation Jump to search
72 bytes added ,  10:34, 11 September 2022
m
Text replacement - "<source" to "<syntaxhighlight"
m (Text replacement - "</source>" to "</syntaxhighlight>")
m (Text replacement - "<source" to "<syntaxhighlight")
 
Line 8: Line 8:
* In [[APL2]], [[APLX]] and others, arrays are stranded after operator evaluation and bracket indexing, but before function evaluation.
* In [[APL2]], [[APLX]] and others, arrays are stranded after operator evaluation and bracket indexing, but before function evaluation.
* In [[APL\360]], [[SHARP APL]] and [[J]] stranding is called '''vector notation''' and is a part of token formation rather than execution. Only plain numbers are stranded.
* In [[APL\360]], [[SHARP APL]] and [[J]] stranding is called '''vector notation''' and is a part of token formation rather than execution. Only plain numbers are stranded.
* In [[A+]] a system equivalent to APL\360 is implemented, but is described as part of [[numeric literal]] notation. "Stranding" in A+ refers to vector notation using parentheses and semicolons <source lang=apl inline>(a;b;c)</syntaxhighlight>.
* In [[A+]] a system equivalent to APL\360 is implemented, but is described as part of [[numeric literal]] notation. "Stranding" in A+ refers to vector notation using parentheses and semicolons <syntaxhighlight lang=apl inline>(a;b;c)</syntaxhighlight>.
* [[BQN]] breaks [[backwards compatibility]] with APL and does not allow stranding by juxtaposition even for numbers. Instead, the "ligature" character <code>‿</code> is used for a more explicit variation of stranding.
* [[BQN]] breaks [[backwards compatibility]] with APL and does not allow stranding by juxtaposition even for numbers. Instead, the "ligature" character <code>‿</code> is used for a more explicit variation of stranding.


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</syntaxhighlight> to <source lang=apl inline>0.8</syntaxhighlight> 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 <syntaxhighlight lang=apl inline>f</syntaxhighlight> to <syntaxhighlight lang=apl inline>0.8</syntaxhighlight> three times using the [[Power operator]]:
<source lang=apl>
<syntaxhighlight lang=apl>
f⍣3 0.8
f⍣3 0.8
</syntaxhighlight>
</syntaxhighlight>
In a language which strands before function application, this expression is equivalent to the derived function <source lang=apl inline>f⍣(3,0.8)</syntaxhighlight>. Not what was intended! The two numbers must be separated somehow, for instance with parentheses or a [[Identity|tack function]].
In a language which strands before function application, this expression is equivalent to the derived function <syntaxhighlight lang=apl inline>f⍣(3,0.8)</syntaxhighlight>. Not what was intended! The two numbers must be separated somehow, for instance with parentheses or a [[Identity|tack function]].
<source lang=apl>
<syntaxhighlight lang=apl>
(f⍣3)0.8
(f⍣3)0.8
f⍣3⊢0.8
f⍣3⊢0.8
</syntaxhighlight>
</syntaxhighlight>
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</syntaxhighlight> would have to be written with parentheses <source lang=apl inline>⊥⍤(0 1)</syntaxhighlight>.
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 <syntaxhighlight lang=apl inline>⊥⍤0 1</syntaxhighlight> would have to be written with parentheses <syntaxhighlight lang=apl inline>⊥⍤(0 1)</syntaxhighlight>.


== External links ==
== External links ==

Navigation menu