Suffix: Difference between revisions
Jump to navigation
Jump to search
no edit summary
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...") |
Miraheze>Marshall No edit summary |
||
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 [[ | 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 ← {((≢⍺)≤(≢⍵)) ∧ ⍺≡(-≢⍺)↑⍵} |