Strand notation: Difference between revisions
Jump to navigation
Jump to search
no edit summary
Miraheze>Marshall No edit summary |
Miraheze>Adám Brudzewsky No edit summary |
||
Line 2: | Line 2: | ||
Several variations on stranding exist: | Several variations on stranding exist: | ||
* [[SHARP APL]] | * [[SHARP APL]] have no notion of array stranding. | ||
* In [[APL2]] arrays are stranded before operator or function evaluation. | * In [[APL2]] arrays are stranded before operator or function evaluation. | ||
* In some APLs (???) arrays are stranded after operator evaluation but before function evaluation. | * In some APLs (???) arrays are stranded after operator evaluation but before function evaluation. | ||
Line 8: | Line 8: | ||
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]]: | 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]]: | ||
< | <source lang=apl> | ||
f⍣3 0.8 | f⍣3 0.8 | ||
</ | </source> | ||
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]]. | 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]]. | ||
< | <source lang=apl> | ||
(f⍣3)0.8 | (f⍣3)0.8 | ||
f⍣3⊢0.8 | f⍣3⊢0.8 | ||
</ | </source> | ||
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>. | 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>. | ||