Or (∨
) is a dyadic scalar boolean function which tests if at least one of the two arguments is true: it returns 1 if at least one side is 1 and 0 if both are 0. It represents the logical disjunction in Boolean logic.
Examples
The following shows all possible combinations of inputs as a Boolean function.
0 0 1 1 ∨ 0 1 0 1
0 1 1 1
When combined with Reduce, Or can be used to test if some value in a Boolean vector is true.
∨/ 0 0 1 0 1
1
∨/ 0 0 0 0 0
0
Extended definition
Many APL implementations extend this function to non-Boolean arguments. In this case, this function behaves as Greatest Common Divisor or GCD. For positive integer arguments, it is defined as the largest positive number which divides both numbers. If one of the arguments is zero, the GCD function returns the other number. While the mathematical definition of GCD does not cover non-integers, some implementations accept them as arguments, returning a value which, when dividing both arguments, gives integers (or Gaussian integers, when given complex numbers).
∘.∨⍨ 0,⍳10
0 1 2 3 4 5 6 7 8 9 10
1 1 1 1 1 1 1 1 1 1 1
2 1 2 1 2 1 2 1 2 1 2
3 1 1 3 1 1 3 1 1 3 1
4 1 2 1 4 1 2 1 4 1 2
5 1 1 1 1 5 1 1 1 1 5
6 1 2 3 2 1 6 1 2 3 2
7 1 1 1 1 1 1 7 1 1 1
8 1 2 1 4 1 2 1 8 1 2
9 1 1 3 1 1 3 1 1 9 1
10 1 2 1 2 5 2 1 2 1 10
0.6∨13÷3
0.06666666667
0.6(13÷3)÷0.6∨13÷3
9 65
2J2∨3J1
1J1
2J2 3J1÷1J1
2 2J¯1
External links
Documentation
APL built-ins [edit]
|
Primitives (Timeline) |
Functions
|
Scalar
|
Monadic
|
Conjugate ∙ Negate ∙ Signum ∙ Reciprocal ∙ Magnitude ∙ Exponential ∙ Natural Logarithm ∙ Floor ∙ Ceiling ∙ Factorial ∙ Not ∙ Pi Times ∙ Roll ∙ Type ∙ Imaginary ∙ Square Root ∙ Round
|
Dyadic
|
Add ∙ Subtract ∙ Times ∙ Divide ∙ Residue ∙ Power ∙ Logarithm ∙ Minimum ∙ Maximum ∙ Binomial ∙ Comparison functions ∙ Boolean functions (And, Or, Nand, Nor) ∙ GCD ∙ LCM ∙ Circular ∙ Complex ∙ Root
|
Non-Scalar
|
Structural
|
Shape ∙ Reshape ∙ Tally ∙ Depth ∙ Ravel ∙ Enlist ∙ Table ∙ Catenate ∙ Reverse ∙ Rotate ∙ Transpose ∙ Raze ∙ Mix ∙ Split ∙ Enclose ∙ Nest ∙ Cut (K) ∙ Pair ∙ Link ∙ Partitioned Enclose ∙ Partition
|
Selection
|
First ∙ Pick ∙ Take ∙ Drop ∙ Unique ∙ Identity ∙ Stop ∙ Select ∙ Replicate ∙ Expand ∙ Set functions (Intersection ∙ Union ∙ Without) ∙ Bracket indexing ∙ Index ∙ Cartesian Product ∙ Sort
|
Selector
|
Index generator ∙ Grade ∙ Index Of ∙ Interval Index ∙ Indices ∙ Deal ∙ Prefix and suffix vectors
|
Computational
|
Match ∙ Not Match ∙ Membership ∙ Find ∙ Nub Sieve ∙ Encode ∙ Decode ∙ Matrix Inverse ∙ Matrix Divide ∙ Format ∙ Execute ∙ Materialise ∙ Range
|
Operators |
Monadic
|
Each ∙ Commute ∙ Constant ∙ Replicate ∙ Expand ∙ Reduce ∙ Windowed Reduce ∙ Scan ∙ Outer Product ∙ Key ∙ I-Beam ∙ Spawn ∙ Function axis ∙ Identity (Null, Ident)
|
Dyadic
|
Bind ∙ Compositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner Product ∙ Determinant ∙ Power ∙ At ∙ Under ∙ Rank ∙ Depth ∙ Variant ∙ Stencil ∙ Cut ∙ Direct definition (operator) ∙ Identity (Lev, Dex)
|
Quad names
|
Index origin ∙ Comparison tolerance ∙ Migration level ∙ Atomic vector
|