# Reverse Compose: Difference between revisions

 `⍛`

Reverse Compose (`⍛`), also known as Before, is a primitive operator closely related to Beside (`∘`), 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 f⍛g 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. Its dyadic case matches I's Hook (`h`), which is a reflected form of a J Hook, while Backhook (`H`) matches the ordinary Hook or Compose: because I's precedence order is left to right, it considers the "reversed" APL form to be primary. The monadic case was discussed for a while in the APL Orchard. To be completely consistent with the other function composition, the left "leg" would be removed, making `f⍛g Y` be equivalent to `g Y`. However, this would never apply `f` and would questionably be called a composition of `f` and `g`. Instead, it was concluded that the best solution would be to have `f⍛g Y` be a hook, `f⍛g⍨Y`, that is, `f⍛g` ${\displaystyle \Leftrightarrow }$ `f⍛g⍨⍨`.

## 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 Beside to create the split-compose construct. Here, we take the sign of the left argument and apply it to (that is, multiply it with) the absolute value of the right argument:

Try it online!

```      3 ¯1 4×⍛×∘|¯2 ¯7 1
2 ¯7 1
```
APL built-ins 
Primitive functions
Scalar
Non-Scalar
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)