Suffix: Difference between revisions

Jump to navigation Jump to search
28 bytes added ,  14:10, 30 April 2020
m
Array relationships category
Miraheze>Marshall
(Created page with "A '''suffix''' is a kind of subarray which is like a prefix except that values are taken from the end of the array rather than the beginning: a vector is a suffix...")
 
m (Array relationships category)
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
A '''suffix''' is a kind of [[subarray]] which is like a [[prefix]] except that values are taken from the end of the array rather than the beginning: a [[vector]] is a suffix of another vector if it is no longer than that vector, and shares all of its trailing [[element]]s. In [[leading axis theory]], an array may be considered a suffix of another array of the same [[rank]] if the same relation holds with [[major cell]]s in place of elements. The function [[Drop]] produces suffixes of its right argument when the left argument is non-negative.
A '''suffix''' is a kind of [[subarray]] which is like a [[prefix]] except that values are taken from the end of the array rather than the beginning: a [[vector]] is a suffix of another vector if it is no longer than that vector, and shares all of its trailing [[element]]s. In [[leading axis theory]], an array may be considered a suffix of another array of the same [[rank]] if the same relation holds with [[major cell]]s in place of elements. The function [[Drop]] produces suffixes of its right argument when the left argument is non-negative.


In analogy to [[prefix]] testing, whether an array is a suffix may be tested using [[Take]] with a [[Minus|negated]] 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.
<source lang=apl>
<source lang=apl>
       isSuffix ← {((≢⍺)≤(≢⍵)) ∧ ⍺≡(-≢⍺)↑⍵}
       isSuffix ← {((≢⍺)≤(≢⍵)) ∧ ⍺≡(-≢⍺)↑⍵}
Line 18: Line 18:


[[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]]. The earliest versions of [[APL\360]] adapted this notation by defining a suffix function <source lang=apl inline>n ⍵ j</source> before removing it in favor of [[Take]] with a negative left argument.
[[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]]. The earliest versions of [[APL\360]] adapted this notation by defining a suffix function <source lang=apl inline>n ⍵ j</source> before removing it in favor of [[Take]] with a negative left argument.
[[Category:Array relationships]]

Navigation menu