# Reverse Compose

(Redirected from Reverse-compose)
Jump to navigation Jump to search
 `⍛`

Reverse Compose (`⍛`) or Behind is a primitive operator closely related to Beside (`∘`), which appears in Extended Dyalog APL and dzaima/APL. 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 `{(⍺⍺ ⍺) ⍵⍵ ⍵}`. This dyadic definition matches the hook function Before, represented as `⊸` in BQN.

Unlike Before, the monadic case of Reverse Compose has differed across implementations. When introduced by Extended Dyalog APL, `f⍛g Y` evaluated to `g Y`, but the later Dyalog APL Vision defines[1] it to be `(f Y) g Y`, matching Before. This later definition might also be written `f⍛g` ${\displaystyle \Leftrightarrow }$ `f⍛g⍨⍨` ${\displaystyle \Leftrightarrow }$ `g⍨∘f⍨`. In dzaima/APL the monadic case is simply an error.

## 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
```