Split composition: Difference between revisions
(Use in I)
mNo edit summary
|Line 16:||Line 16:|
, split-compose is precisely equivalent to a [[fork]].
Revision as of 14:46, 12 April 2022
Split-compose is a point-free construct, used to pre-process its argument(s) with the left and right-most operand before applying the middle operand between the result. The name was introduced by the I language, where it's represented with
O, a higher-order function that applies first to the middle function and then the two outer functions (
O also represents the Over operator). It doesn't appear as a primitive in any APL.
H, the split composition on arguments
y is defined as
(F x) G (H y).
5 ↕⊸×⟜| 5‿¯8‿¯2‿¯5‿3 ⟨ 0 8 4 15 12 ⟩
+´⊸÷⟜≠ ↕10 ⟨ 4.5 ⟩ # This is evaluated as (↕10) +´⊸÷⟜≢ ↕10
In this case, split-compose is precisely equivalent to a fork.
(+´÷≠) ↕10 4.5
In dialects that lack Before, split-compose can be defined differently.
÷⍨∘(+/)⍨∘≢⍨⍨ ⍳10 4.5
Whilst these expressions will return the same results (if the functions f, g, and h are pure) the evaluation order is not identical.
And (most commonly) as a fork:
f⍤⊣ g h⍤⊢