Difference between revisions of "Reverse Compose"

From APL Wiki
Jump to navigation Jump to search
(Created page with "{{Built-in|Reverse compose|⍛}}, also known as '''Before''', is a primitive operator closely related to Compose (<source lang=apl inline>∘</source>...")
(No difference)

Revision as of 14:26, 12 February 2020

Reverse compose (), also known as Before, is a primitive operator closely related to Compose (), also known as After. Called dyadically with function operands f and g, it uses f monadically to pre-processes the left argument before applying g between the pre-processed left argument and the given right argument. X fg Y is thus equivalent to (f X) g Y. The operator can be defined as the dop {(⍺⍺ ) ⍵⍵ }. Reverse compose was introduced in Extended Dyalog APL, and then adopted into dzaima/APL.

Common usage

Its plain usage is to pre-process left arguments without needing one or more applications of Commute (). For example, the square of the left argument minus the right argument can be expressed as:

Try it online!

      3×-2
7

It can also be combined with Compose to create the split-compose construct. Here, we take the sign of the left argument and apply it to the absolute value of the right argument:

Try it online!

      3 ¯1 4××|¯2 ¯7 1
2 ¯7 1
APL built-ins [edit]
Primitive functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Selector Index generatorGradeIndex OfInterval IndexIndicesDeal
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-beamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Case convertUnicode convert
Operators SearchReplace