Difference between revisions of "Membership"

From APL Wiki
Jump to navigation Jump to search
(Created page with "{{Built-in|Membership|∊}}, also called '''Member Of''' or '''Member In''', is a dyadic primitive function which tests if each of the elements of the left [[argument]...")
(No difference)

Revision as of 05:33, 29 June 2020

Membership (), also called Member Of or Member In, is a dyadic primitive function which tests if each of the elements of the left argument appears as an element of the right argument. Membership uses the glyph Epsilon, which resembles the mathematical notation .


Both arguments can be arrays of any shape. Each element of the left argument is tested against elements of the right argument, and the result is a boolean array having the same shape as the left argument.

1 1 0 0 1 0 1 0 0
      3 6 93 3⍴⍳9
1 1 1
      (3 3⍴⍳9)3 6 9
0 0 1
0 0 1
0 0 1

For nested arrays, Membership tests for exact match between the elements.

      'CAT' 'DOG' 'MOUSE'  'CAT' 'FOX' 'DOG' 'LLAMA'
1 1 0

Leading axis model

The behavior of Membership was changed to follow leading axis model in some implementations such as J. In this case, if the right argument is a higher-rank array, the cells of the left argument with appropriate rank are compared against the major cells of the right argument.

      'able' e. mat
      (<'able') e. mat
      'ab' e. mat
      (3 3 4$'able') e. mat  NB. the resulting shape is trailing axes (corresponding to the major cells of mat) removed
1 1 1
1 1 1
1 1 1

External links


APL built-ins [edit]
Primitive functions
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Selector Index generatorGradeIndex OfInterval IndexIndicesDeal
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-beamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Name classCase convertUnicode convert
Operators SearchReplace