Negate

From APL Wiki
Revision as of 14:07, 27 March 2020 by Marshall (talk | contribs) (Created page with ":''This page describes the monadic arithmetic function. For logical negation of a single argument, see Not. For dyadic subtraction (minus), see Subtract.'' {{Built-in...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This page describes the monadic arithmetic function. For logical negation of a single argument, see Not. For dyadic subtraction (minus), see Subtract.
-

Negate (-), or Minus, is a monadic scalar function which returns the additive inverse of its argument. It shares a glyph - with Subtract, which may also be called Minus, and may be considered a case of Subtract with a default left argument of zero.

The function Negate is distinguished from the syntactic negative sign, which is not a function but rather part of numeric literal notation. APL uses the high minus ¯ for the negative sign, but K uses the same symbol - as Minus, treating a - immediately preceding a numeric literal with no spaces as a negative sign.

Examples

Negating a vector of positive numbers. Note that the result array is displayed with a high minus on each element rather than a single Negate. The high minus applies to individual elements while Negate can only negate an entire array.

      - 1 2 3
¯1 ¯2 ¯3

Negate works on every type of number present, including complex numbers.

      - ¯2.5 1e20 3j¯4
2.5 ¯1E20 ¯3J4

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