Less than: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Merge Boolean sections)
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Main|Comparison function}}
{{Main|Comparison function}}
 
:''For the set function, see [[Without]].''
{{Built-in|Less than|<nowiki><</nowiki>}} is a [[comparison function]] which tests whether the left [[argument]] is [[Tolerant comparison|tolerantly]] less than and not equal to the right argument, returning 1 if this is the case and 0 otherwise. It is the [[Not|negation]] of [[Greater than or Equal to]] (<source lang=apl inline>≥</source>). Less-than [[Scan]], which leaves only the first 1 in its argument set<ref>[[Phil Last|Last, Phil]]. [http://archive.vector.org.uk/art10501140 "Boolean Reductions"]. [[Vector Journal]] volume 26, number 1. 2013-09.</ref>, is a notable pattern.
{{Built-in|Less than|<nowiki><</nowiki>}} is a [[comparison function]] which tests whether the left [[argument]] is [[Tolerant comparison|tolerantly]] less than and not equal to the right argument, returning 1 if this is the case and 0 otherwise. It is the [[Not|negation]] of [[Greater than or Equal to]] (<syntaxhighlight lang=apl inline>≥</syntaxhighlight>). Less-than [[Scan]], which leaves only the first 1 in a [[Boolean]] [[vector]] set<ref>[[Phil Last|Last, Phil]]. [http://archive.vector.org.uk/art10501140 "Boolean Reductions"]. [[Vector Journal]] volume 26, number 1. 2013-09.</ref>, is a notable pattern.


== Boolean function ==
== Boolean function ==


When the arguments to Less than are [[Boolean]], it is the [[wikipedia:converse nonimplication|converse nonimplication]] [[Boolean function]]:
When the arguments to Less than are [[Boolean]], it is the [[wikipedia:converse nonimplication|converse nonimplication]] [[Boolean function]]:
{|class=wikitable style="margin:1em auto"
::{|class=wikitable
!<source lang=apl inline><</source>!!<source lang=apl inline>0</source>!!<source lang=apl inline>1</source>
!<syntaxhighlight lang=apl inline><</syntaxhighlight>!!<syntaxhighlight lang=apl inline>0</syntaxhighlight>!!<syntaxhighlight lang=apl inline>1</syntaxhighlight>
|-
|-
!<source lang=apl inline>0</source>
!<syntaxhighlight lang=apl inline>0</syntaxhighlight>
|<source lang=apl inline>0</source>||<source lang=apl inline>1</source>
|<syntaxhighlight lang=apl inline>0</syntaxhighlight>||<syntaxhighlight lang=apl inline>1</syntaxhighlight>
|-
|-
!<source lang=apl inline>1</source>
!<syntaxhighlight lang=apl inline>1</syntaxhighlight>
|<source lang=apl inline>0</source>||<source lang=apl inline>0</source>
|<syntaxhighlight lang=apl inline>0</syntaxhighlight>||<syntaxhighlight lang=apl inline>0</syntaxhighlight>
|}
|}
It returns 1 only if the left argument is 0 and the right argument is 1, and is identical to [[Residue]]. Considered as a logical operation, it can be read as ''isn't, as opposed to''.
It returns 1 only if the left argument is 0 and the right argument is 1, and is identical to [[Residue]]. Considered as a logical operation, it can be read as ''isn't, as opposed to''.


Less-than [[Scan]] on a Boolean [[vector]] returns a vector which indicates the position of the first 1 in the argument, if any:
Less-than [[Scan]] on a Boolean [[vector]] returns a vector which indicates the position of the first 1 in the argument, if any:
<source lang=apl>
<syntaxhighlight lang=apl>
       <\ 0 0 1 0 0 0 1 0
       <\ 0 0 1 0 0 0 1 0
0 0 1 0 0 0 0 0
0 0 1 0 0 0 0 0
</source>
</syntaxhighlight>
It is idiom 348, "First one", in the [[FinnAPL idiom library]].
It is idiom 348, "First one", in the [[FinnAPL idiom library]].


Line 28: Line 28:
=== Documentation ===
=== Documentation ===


* [http://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Less.htm Dyalog]
* [https://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Less.htm Dyalog]
* [http://microapl.com/apl_help/ch_020_020_290.htm APLX]
* [http://microapl.com/apl_help/ch_020_020_290.htm APLX]
* J [http://www.jsoftware.com/help/dictionary/d010.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/lt#dyadic NuVoc]
* J [http://www.jsoftware.com/help/dictionary/d010.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/lt#dyadic NuVoc]
* [https://mlochbaum.github.io/BQN/doc/arithmetic.html#comparisons BQN]


== References ==
== References ==
<references />
<references />
{{APL built-ins}}
{{APL built-ins}}[[Category:Primitive functions]][[Category:Comparison functions]]

Latest revision as of 22:11, 10 September 2022

Main article: Comparison function
For the set function, see Without.
<

Less than (<) is a comparison function which tests whether the left argument is tolerantly less than and not equal to the right argument, returning 1 if this is the case and 0 otherwise. It is the negation of Greater than or Equal to (). Less-than Scan, which leaves only the first 1 in a Boolean vector set[1], is a notable pattern.

Boolean function

When the arguments to Less than are Boolean, it is the converse nonimplication Boolean function:

< 0 1
0 0 1
1 0 0

It returns 1 only if the left argument is 0 and the right argument is 1, and is identical to Residue. Considered as a logical operation, it can be read as isn't, as opposed to.

Less-than Scan on a Boolean vector returns a vector which indicates the position of the first 1 in the argument, if any:

      <\ 0 0 1 0 0 0 1 0
0 0 1 0 0 0 0 0

It is idiom 348, "First one", in the FinnAPL idiom library.

External links

Documentation

References

  1. Last, Phil. "Boolean Reductions". Vector Journal volume 26, number 1. 2013-09.
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