Split composition

From APL Wiki
Revision as of 12:30, 12 April 2022 by Awagga (talk | contribs) (Created page with "'''Split-compose''' is a point-free construct, used to pre-process the argument(s) with the left, and right-most operand before applying the middle operand between the result....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Split-compose is a point-free construct, used to pre-process the argument(s) with the left, and right-most operand before applying the middle operand between the result.

It's definition is specified as (F x) G (H y).

In BQN, the construct can be formed using Before (⊸) and After (⟜), two compositional operators. In this example, we multiply the range of the left argument, with the absolute value of the right.

    5 ↕⊸×⟜| 5‿¯8‿¯2‿¯5‿3
⟨ 0 8 4 15 12 ⟩

Monadically, the right argument can be duplicated and split-compose will be applied asymmetrically, similar to hook

    +´⊸÷⟜≠ ↕10 
⟨ 4.5 ⟩
# This is evaluated as (↕10) +´⊸÷⟜≢ ↕10

Monadically, split-compose is precisely equivalent to a fork.

    (+´÷≠) ↕10
4.5


In dialects that lack Before, split-compose can be defined differently.

In Dyalog APL you may form the expression with Beside (∘) and Commute (⍨)

g∘h⍨∘f⍨
g⍨∘f⍨∘h⍨⍨

For example:

     ÷⍨∘(+/)⍨∘≢⍨⍨ ⍳10
4.5

Whilst these expressions will return the same results (if the functions f,g, & h are pure) the evaluation order is not identical.

And (most commonly) as a fork:

f⍤⊣ g h⍤⊢