Subarray: Difference between revisions

Jump to navigation Jump to search
36 bytes added ,  11:02, 11 September 2022
m
Text replacement - "<source" to "<syntaxhighlight"
m (Text replacement - " ⊢( *[^∘])" to " ⎕←$1")
m (Text replacement - "<source" to "<syntaxhighlight")
(One intermediate revision by the same user not shown)
Line 5: Line 5:
A vector subarray of a [[vector]] is a subvector. In languages outside of the APL family which have only 1-dimensional arrays, "subarray" may have this meaning: for example, the [[wikipedia:maximum subarray problem|maximum subarray problem]] is usually taken to apply to 1-dimensional arrays only. The term "slice" may also be used to refer to a subvector outside of APL.
A vector subarray of a [[vector]] is a subvector. In languages outside of the APL family which have only 1-dimensional arrays, "subarray" may have this meaning: for example, the [[wikipedia:maximum subarray problem|maximum subarray problem]] is usually taken to apply to 1-dimensional arrays only. The term "slice" may also be used to refer to a subvector outside of APL.


The [[Find]] (<source lang=apl inline>⍷</source>) function searches for occurrences of the left argument as a subarray of the right argument. For Find, a subarray may have leading axes dropped but not others. We might also say that Find searches for the left argument after extending its [[shape]] with leading 1s, or that it searches for the left argument as a subarray of any equal-[[rank]] [[cell]] of the right argument.
The [[Find]] (<syntaxhighlight lang=apl inline>⍷</syntaxhighlight>) function searches for occurrences of the left argument as a subarray of the right argument. For Find, a subarray may have leading axes dropped but not others. We might also say that Find searches for the left argument after extending its [[shape]] with leading 1s, or that it searches for the left argument as a subarray of any equal-[[rank]] [[cell]] of the right argument.
<source lang=apl>
<syntaxhighlight lang=apl>
       ⎕←A ← 5 4⍴⎕A
       ⎕←A ← 5 4⍴⎕A
ABCD
ABCD
Line 37: Line 37:
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
</source>
</syntaxhighlight>


Special types of equal-rank subarrays include:
Special types of equal-rank subarrays include:

Navigation menu