Topic: `APLX Help` : `Help on APL language` : `APL Primitives` : `∊ Membership`
[ Previous | Next | Contents | Index | APL Home ]

# `∊` Membership

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)
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
Topic: `APLX Help` : `Help on APL language` : `APL Primitives` : `∊ Membership`