And: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{Built-in|And|∧}} is a [[dyadic]] [[scalar function|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 [[wikipedia:logical conjunction|logical conjunction]] in Boolean logic. | {{Built-in|And|∧}} is a [[dyadic]] [[scalar function|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 [[wikipedia:logical conjunction|logical conjunction]] in Boolean logic. In many APLs, And is a special case of the [[LCM]] function. | ||
{|class=wikitable | {|class=wikitable | ||
!< | !<syntaxhighlight lang=apl inline>∧</syntaxhighlight>!!<syntaxhighlight lang=apl inline>0</syntaxhighlight>!!<syntaxhighlight lang=apl inline>1</syntaxhighlight> | ||
|- | |- | ||
!< | !<syntaxhighlight lang=apl inline>0</syntaxhighlight> | ||
|< | |<syntaxhighlight lang=apl inline>0</syntaxhighlight>||<syntaxhighlight lang=apl inline>0</syntaxhighlight> | ||
|- | |- | ||
!< | !<syntaxhighlight 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. | ||
< | <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 | ||
</ | </syntaxhighlight> | ||
When combined with [[Reduce]], And can be used to test if every value in a Boolean vector is true. | |||
<syntaxhighlight lang=apl> | |||
∧/ 1 1 1 1 1 | |||
1 | |||
∧/ 1 0 0 1 1 | |||
0 | |||
</syntaxhighlight> | |||
== See also == | |||
* [[Times]] | |||
* [[Minimum]] | |||
* [[Intersection]] | |||
* [[Nand]] | |||
* [[Or]] | |||
== External links == | == External links == | ||
Line 52: | Line 40: | ||
=== Documentation === | === Documentation === | ||
* [ | * [https://help.dyalog.com/17.1/#Language/Primitive%20Functions/And%20Lowest%20Common%20Multiple.htm Dyalog] | ||
* [http://microapl.com/apl_help/ch_020_020_430.htm APLX] | |||
* J [https://www.jsoftware.com/help/dictionary/d111.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/stardot#dyadic NuVoc] | * J [https://www.jsoftware.com/help/dictionary/d111.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/stardot#dyadic NuVoc] | ||
* [https://mlochbaum.github.io/BQN/doc/logic.html BQN] | |||
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]] | {{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]] |
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
- Dyalog
- APLX
- J Dictionary, NuVoc
- BQN