Find: Difference between revisions
From NARS2000
Jump to navigationJump to search
(Created page with "<apll> Z←L⍷R </apll> <p> <br> <b>Find</b> looks for patterns <apll>R</apll> in <apll>L</apll>. <br> It returns a simple boolean array with the same shape as <apll>L</apll>...") |
Sudleyplace (talk | contribs) No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
<apll> | <table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> | ||
Z←L⍷R | <tr> | ||
</apll> | <td> | ||
< | <table border="0" cellpadding="5" cellspacing="0" summary=""> | ||
< | <tr> | ||
< | <td valign="top"><apll>Z←L⍷R</apll></td> | ||
< | <td></td> | ||
<apll>L</apll> and <apll>R</apll> are arbitrary arrays. | <td></td> | ||
<td>finds the matches of <apll>L</apll> in <apll>R</apll>.</td> | |||
</tr> | |||
</table> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td><apll>L</apll> and <apll>R</apll> are arbitrary arrays of any rank, shape, or datatype. | |||
But to be useful, | But to be useful, | ||
the rank of <apll> | <ul> | ||
should not be more than the rank of <apll>L</apll> | <li>the rank of <apll>L</apll> should not be more than the rank of <apll>R</apll></li> | ||
<li>the shape of <apll>L</apll> padded with enough leading <apll>1</apll>s to equal the rank of <apll>R</apll> should be less than or equal to the shape of <apll>R</apll></li> | |||
(either both character or both numeric). | <li>both arguments should have the same type (either both character or both numeric)</li> | ||
< | </ul> | ||
otherwise the result is all zero.</td> | |||
</tr> | |||
< | <tr> | ||
<td><apll>Z</apll> is a Boolean array of the same rank and shape as <apll>R</apll> where each <apll>1</apll> represents the upper left corner of a place in <apll>R</apll> of a match with <apll>L</apll>. | |||
</td> | |||
</tr> | |||
< | </table> | ||
< | If <apll>L</apll> is a scalar, then <apll>L⍷R ←→ R∊L</apll>. | ||
< | |||
< | |||
< | |||
< | If <apll>L</apll> is not a scalar, then it represents a contiguous pattern, | ||
which may or may not be found in one or more places in <apll>R</apll>. | |||
< | |||
< | |||
< | If the arguments are numeric, then the result is sensitive to <apll>⎕CT</apll>. | ||
< | For example: | ||
< | |||
<apll><pre> | |||
R←3 8⍴'thirteenfourteenfifteen ' | |||
R | |||
thirteen | |||
fourteen | |||
fifteen | |||
't'⍷R | |||
1 0 0 0 1 0 0 0 | |||
0 0 0 0 1 0 0 0 | |||
0 0 0 1 0 0 0 0 | |||
'teen'⍷R | |||
0 0 0 0 1 0 0 0 | |||
0 0 0 0 1 0 0 0 | |||
0 0 0 1 0 0 0 0 | |||
(2 4⍴'teen')⍷R | |||
0 0 0 0 1 0 0 0 | |||
0 0 0 0 0 0 0 0 | |||
0 0 0 0 0 0 0 0 | |||
</pre></apll> |
Latest revision as of 17:28, 15 April 2018
|
||||
L and R are arbitrary arrays of any rank, shape, or datatype.
But to be useful,
|
||||
Z is a Boolean array of the same rank and shape as R where each 1 represents the upper left corner of a place in R of a match with L. |
If L is a scalar, then L⍷R ←→ R∊L.
If L is not a scalar, then it represents a contiguous pattern, which may or may not be found in one or more places in R.
If the arguments are numeric, then the result is sensitive to ⎕CT.
For example:
R←3 8⍴'thirteenfourteenfifteen ' R thirteen fourteen fifteen 't'⍷R 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 'teen'⍷R 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 (2 4⍴'teen')⍷R 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0