## ¹ Membership

Two-argument form See also one-argument form Enlist

Checks on whether a data element exists in the right argument. It returns 1 for each element of the left argument found in the right argument and 0 for each element of the left argument not found in the right argument. (This operation is affected by ŒCT, the comparison tolerance)

The arguments compared need not have the same number of elements, nor need they have the same number of dimensions. The result has the same shape as the left argument. See ¦ (Match) for a discussion of the criteria which determine whether two data elements are considered the same.

                 4 ¹ 4 4 5
           1                             (1 means 4 is found in 4 4 5)
                 'A' ¹ 'ABRACADABRA'
           1                             (A is in ABRACADABRA)
                 'ABRACADABRA' ¹ 'A'
           1 0 0 1 0 1 0 1 0 0 1

(Elements 1 4 6 8 and 11 of the left-hand argument occur in the right-hand argument.)

                 'A B C' ¹ 'ABCDE'
           1 0 1 0 1                     (The 0s represent spaces in 'A B C'
                                          which don't occur in 'ABCDE')
                 12 24 36 ¹ 6 12 18 24 30 36
           1 1 1                         (Vectors don't need to have the same
                                          number of elements)
                 TABLE „ 3 3 ½ 1 2 3 4 5 6 7 8 9
                 3 6 9 ¹ TABLE
           1 1 1
                 TABLE ¹ 3 6 9           (Notice that the result always has
           0 0 1                          the same shape as the left-hand
           0 0 1                          argument)
           0 0 1
                 '4' ¹ ¼10               (The character '4' does not appear in
           0                              the numeric vector ¼10)
                 NAMES„'JOHN' 'MARY' 'HARRY'
                 ½NAMES                  (3 element vector)
           3
                 'MARY'¹NAMES            (None of the 4 characters 'MARY' are
           0 0 0 0                        elements in NAMES)
                 (›'MARY')¹NAMES         (The scalar containing 'MARY' does exist in
           1                              NAMES)
                 NAMES¹›'MARY'           (Those  elements of names which contain the
           0 1 0                          scalar 'MARY')
                 'MARY' 'JIM' 'JOHN' ¹ NAMES
           1 0 1                         ('JIM' not found in NAMES)

Topic: APLX Help : Help on APL language : APL Primitives : ¹ Membership

[ Previous | Next | Contents | Index ]