Find

From NARS2000
Revision as of 13:12, 3 December 2016 by Drab (talk | contribs) (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>...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Z←L⍷R


Find looks for patterns R in L.
It returns a simple boolean array with the same shape as L.

L and R are arbitrary arrays. But to be useful, the rank of R should not be more than the rank of L, and both arguments should have the same type (either both character or both numeric).

If R is a scalar, then Z←L⍷R ←→ L∊R.
If R is not a scalar, then it represents a contiguous pattern, which may or may not be found in one or more places in L.

If the arguments are numeric, then the result is sensitive to ⎕CT.

Examples:


       L←3 8⍴'thirteenfourteenfifteen '
       L
thirteen
fourteen
fifteen


       L⍷'t'
1 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 1 0 0 0 0


       L⍷'teen'
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 1 0 0 0 0