## º Find

Find searches for instances of the left argument within the right argument. A boolean result is returned with a 1 where the start of the left argument is found in the right argument. The shape of the result is the same as the shape of the right argument.

                 'ME'º'HOME AGAIN'       (Find the pattern 'ME' in 'HOME AGAIN')
           0 0 1 0 0 0 0 0 0 0
                 WEEK
           SUNDAY
           MONDAY
           TUESDAY
           WEDNESDAY
           THURSDAY
           FRIDAY
           SATURDAY
                 'DAY' º WEEK            (Find the pattern 'DAY' in WEEK)
           0 0 0 1 0 0 0 0 0
           0 0 0 1 0 0 0 0 0
           0 0 0 0 1 0 0 0 0
           0 0 0 0 0 0 1 0 0
           0 0 0 0 0 1 0 0 0
           0 0 0 1 0 0 0 0 0
           0 0 0 0 0 1 0 0 0
                 WEEK º 'DAY'            (WEEK not found in 'DAY' - wrong rank)
           0 0 0

The arguments can be of any rank, but º always searches for the whole of the left argument in the right argument.

                 (1 2) (3 4) º 'START' (1 2 3) (1 2) (3 4)
           0 0 1 0                       (Search within nested vector)
                 MAT
            1  2  3  4  5
            6  7  8  9 10
           11 12 13 14 15
           16 17 18 19 20
                 (2 2½7 8 12 13)ºMAT     (Search pattern is a matrix)
           0 0 0 0 0                     (1 shows top left corner)
           0 1 0 0 0
           0 0 0 0 0
           0 0 0 0 0

See also the system function ŒSS for string search operations on vectors.

Topic: APLX Help : Help on APL language : APL Primitives : º Find

[ Previous | Next | Contents | Index ]