And: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (Text replacement - "</source>" to "</syntaxhighlight>")
m (Text replacement - "<source" to "<syntaxhighlight")
 
Line 2: Line 2:


{|class=wikitable
{|class=wikitable
!<source lang=apl inline>∧</syntaxhighlight>!!<source lang=apl inline>0</syntaxhighlight>!!<source lang=apl inline>1</syntaxhighlight>
!<syntaxhighlight lang=apl inline>∧</syntaxhighlight>!!<syntaxhighlight lang=apl inline>0</syntaxhighlight>!!<syntaxhighlight lang=apl inline>1</syntaxhighlight>
|-
|-
!<source lang=apl inline>0</syntaxhighlight>
!<syntaxhighlight lang=apl inline>0</syntaxhighlight>
|<source lang=apl inline>0</syntaxhighlight>||<source lang=apl inline>0</syntaxhighlight>
|<syntaxhighlight lang=apl inline>0</syntaxhighlight>||<syntaxhighlight lang=apl inline>0</syntaxhighlight>
|-
|-
!<source lang=apl inline>1</syntaxhighlight>
!<syntaxhighlight lang=apl inline>1</syntaxhighlight>
|<source lang=apl inline>0</syntaxhighlight>||<source lang=apl inline>1</syntaxhighlight>
|<syntaxhighlight lang=apl inline>0</syntaxhighlight>||<syntaxhighlight lang=apl inline>1</syntaxhighlight>
|}
|}


Line 15: Line 15:
The following shows all possible combinations of inputs as a Boolean function.
The following shows all possible combinations of inputs as a Boolean function.


<source lang=apl>
<syntaxhighlight lang=apl>
       0 0 1 1 ∧ 0 1 0 1
       0 0 1 1 ∧ 0 1 0 1
0 0 0 1
0 0 0 1
Line 22: Line 22:
When combined with [[Reduce]], And can be used to test if every value in a Boolean vector is true.
When combined with [[Reduce]], And can be used to test if every value in a Boolean vector is true.


<source lang=apl>
<syntaxhighlight lang=apl>
       ∧/ 1 1 1 1 1
       ∧/ 1 1 1 1 1
1
1

Latest revision as of 22:08, 10 September 2022

And () is a dyadic scalar boolean function which tests if both arguments are true: it returns 1 if both are 1 and 0 if one or both are 0. It represents the logical conjunction in Boolean logic. In many APLs, And is a special case of the LCM function.

0 1
0 0 0
1 0 1

Examples

The following shows all possible combinations of inputs as a Boolean function.

      0 0 1 1 ∧ 0 1 0 1
0 0 0 1

When combined with Reduce, And can be used to test if every value in a Boolean vector is true.

      ∧/ 1 1 1 1 1
1
      ∧/ 1 0 0 1 1
0

See also

External links

Documentation

APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare RootRound
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axisIdentity (Null, Ident)
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)Identity (Lev, Dex)
Quad names Index originComparison toleranceMigration levelAtomic vector