Prefix: Difference between revisions

Jump to navigation Jump to search
18 bytes added ,  22:08, 10 September 2022
m
Text replacement - "<source" to "<syntaxhighlight"
m (Array relationships category)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 2: Line 2:


A vector is a prefix of another vector if its length is [[Less than or Equal to]] that vector's length, and every [[element]] in the prefix vector [[match]]es the corresponding element of the other vector (the one at the same [[index]]). This may be tested using [[Take]] and [[Match]]:
A vector is a prefix of another vector if its length is [[Less than or Equal to]] that vector's length, and every [[element]] in the prefix vector [[match]]es the corresponding element of the other vector (the one at the same [[index]]). This may be tested using [[Take]] and [[Match]]:
<source lang=apl>
<syntaxhighlight lang=apl>
       isPrefix ← {((≢⍺)≤(≢⍵)) ∧ ⍺≡(≢⍺)↑⍵}
       isPrefix ← {((≢⍺)≤(≢⍵)) ∧ ⍺≡(≢⍺)↑⍵}
       'pre' isPrefix 'prefix'
       'pre' isPrefix 'prefix'
Line 14: Line 14:
In [[leading axis theory]], the [[frame]] for k-cells of an array is a prefix of that array's [[shape]], while the [[cell shape]] is a [[suffix]].
In [[leading axis theory]], the [[frame]] for k-cells of an array is a prefix of that array's [[shape]], while the [[cell shape]] is a [[suffix]].


[[Iverson notation]] included the notion of a prefix vector <math>\alpha^j(n)</math> consisting of <math>j</math> ones followed by <math>n-j</math> zeros; such a vector could be used to produce a length-<math>j</math> prefix of a length-<math>n</math> vector using [[Compress]]. A prefix function <source lang=apl inline>n ⍺ j</source> was included in early versions of [[APL\360]].
[[Iverson notation]] included the notion of a prefix vector <math>\alpha^j(n)</math> consisting of <math>j</math> ones followed by <math>n-j</math> zeros; such a vector could be used to produce a length-<math>j</math> prefix of a length-<math>n</math> vector using [[Compress]]. A prefix function <syntaxhighlight lang=apl inline>n ⍺ j</source> was included in early versions of [[APL\360]].


In [[Dyalog APL]]'s [[Total array ordering]], a prefix of another array always orders earlier than that array; this is a consequence of the principally "nothing is less than something" used as the foundation for Dyalog's TAO.
In [[Dyalog APL]]'s [[Total array ordering]], a prefix of another array always orders earlier than that array; this is a consequence of the principally "nothing is less than something" used as the foundation for Dyalog's TAO.


[[Category:Array relationships]]
[[Category:Array relationships]]

Navigation menu