2,954
edits
m (Text replacement - "</source>" to "</syntaxhighlight>") Tags: Mobile edit Mobile web edit |
(Prefix and Suffix vectors now have a page) |
||
(One intermediate revision by one other user not shown) | |||
Line 2: | Line 2: | ||
In analogy to [[prefix]] testing, whether an array is a suffix may be tested using [[Take]] with a [[negate]]d left argument and [[Match]]. The only difference is the negation. | In analogy to [[prefix]] testing, whether an array is a suffix may be tested using [[Take]] with a [[negate]]d left argument and [[Match]]. The only difference is the negation. | ||
< | <syntaxhighlight lang=apl> | ||
isSuffix ← {((≢⍺)≤(≢⍵)) ∧ ⍺≡(-≢⍺)↑⍵} | isSuffix ← {((≢⍺)≤(≢⍵)) ∧ ⍺≡(-≢⍺)↑⍵} | ||
'fix' isSuffix 'suffix' | 'fix' isSuffix 'suffix' | ||
Line 9: | Line 9: | ||
0 | 0 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
We can also use an < | We can also use an <syntaxhighlight lang=apl inline>isPrefix</syntaxhighlight> function directly by [[Reverse|reversing]] both its arguments. In the second definition below, this relation is written more succinctly in a [[tacit]] style using the [[Over]] operator. | ||
< | <syntaxhighlight lang=apl> | ||
isSuffix ← {(⊖⍺)isPrefix(⊖⍵)} | isSuffix ← {(⊖⍺)isPrefix(⊖⍵)} | ||
isSuffix ← isPrefix⍥⊖ | isSuffix ← isPrefix⍥⊖ | ||
Line 17: | Line 17: | ||
In [[leading axis theory]], the [[cell shape]] of each k-[[cell]] in an array is a suffix of that array's [[shape]], while the [[frame]] is a [[prefix]] of the shape. | In [[leading axis theory]], the [[cell shape]] of each k-[[cell]] in an array is a suffix of that array's [[shape]], while the [[frame]] is a [[prefix]] of the shape. | ||
[[Iverson notation]] included the notion of a suffix vector <math>\omega^j(n)</math> consisting of <math>n-j</math> zeros followed by <math>j</math> ones; such a vector could be used to produce a length-<math>j</math> suffix of a length-<math>n</math> vector using [[Compress]] | [[Iverson notation]] and very early APLs included the notion of a [[suffix vector]] <math>\omega^j(n)</math> consisting of <math>n-j</math> zeros followed by <math>j</math> ones; such a vector could be used to produce a length-<math>j</math> suffix of a length-<math>n</math> vector using [[Compress]]. | ||
[[Category:Array relationships]] | [[Category:Array relationships]] |