Reverse Compose: Difference between revisions

Jump to navigation Jump to search
April implemented this (as Before) before Kap actually
(Kap)
(April implemented this (as Before) before Kap actually)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Built-in|Reverse Compose|⍛}} or '''Behind''' is a [[primitive operator]] closely related to [[Beside]] (<syntaxhighlight lang=apl inline>∘</syntaxhighlight>), which appears in [[Extended Dyalog APL]], [[dzaima/APL]], and [[Kap]]. Called [[dyad|dyadically]] with function operands <syntaxhighlight lang=apl inline>f</syntaxhighlight> and <syntaxhighlight lang=apl inline>g</syntaxhighlight>, it uses <syntaxhighlight lang=apl inline>f</syntaxhighlight> [[monad|monadically]] to pre-processes the left argument before applying <syntaxhighlight lang=apl inline>g</syntaxhighlight> between the pre-processed left argument and the given right argument. <syntaxhighlight lang=apl inline>X f⍛g Y</syntaxhighlight> is thus equivalent to <syntaxhighlight lang=apl inline>(f X) g Y</syntaxhighlight>. The operator can be defined as the [[dop]] <syntaxhighlight lang=apl inline>{(⍺⍺ ⍺) ⍵⍵ ⍵}</syntaxhighlight>. This dyadic definition matches the [[hook]] function Before, represented as <code>⊸</code> in [[BQN]].
{{Built-in|Reverse Compose|⍛}} or '''Before''' is a [[primitive operator]] closely related to [[Beside]] (<syntaxhighlight lang=apl inline>∘</syntaxhighlight>), which appears in [[Extended Dyalog APL]], [[dzaima/APL]], [[April]] and [[Kap]]. Called [[dyad|dyadically]] with function operands <syntaxhighlight lang=apl inline>f</syntaxhighlight> and <syntaxhighlight lang=apl inline>g</syntaxhighlight>, it uses <syntaxhighlight lang=apl inline>f</syntaxhighlight> [[monad|monadically]] to pre-processes the left argument before applying <syntaxhighlight lang=apl inline>g</syntaxhighlight> between the pre-processed left argument and the given right argument. <syntaxhighlight lang=apl inline>X f⍛g Y</syntaxhighlight> is thus equivalent to <syntaxhighlight lang=apl inline>(f X) g Y</syntaxhighlight>. The operator can be defined as the [[dop]] <syntaxhighlight lang=apl inline>{(⍺⍺ ⍺) ⍵⍵ ⍵}</syntaxhighlight>. This dyadic definition matches the [[hook]] function Before, represented as <code>⊸</code> in [[BQN]].


Unlike Before, the [[monad]]ic case of Reverse Compose has differed across implementations. When introduced by [[Extended Dyalog APL]], <syntaxhighlight lang=apl inline>f⍛g Y</syntaxhighlight> evaluated to <syntaxhighlight lang=apl inline>g Y</syntaxhighlight>, but the later [[Dyalog APL Vision]], and [[Kap]], define it to be <syntaxhighlight lang=apl inline>(f Y) g Y</syntaxhighlight>, matching Before. This later definition might also be written <syntaxhighlight lang=apl inline>f⍛g</syntaxhighlight>{{←→}}<syntaxhighlight lang=apl inline>f⍛g⍨⍨</syntaxhighlight>{{←→}}<syntaxhighlight lang=apl inline>g⍨∘f⍨</syntaxhighlight>. In [[dzaima/APL]] the monadic case is simply an error.
Unlike Before, the [[monad]]ic case of Reverse Compose has differed across implementations. When introduced by [[Extended Dyalog APL]], <syntaxhighlight lang=apl inline>f⍛g Y</syntaxhighlight> evaluated to <syntaxhighlight lang=apl inline>g Y</syntaxhighlight>, but the later [[Dyalog APL Vision]], as well as [[April]] and [[Kap]], define it to be <syntaxhighlight lang=apl inline>(f Y) g Y</syntaxhighlight>, matching Before. This later definition might also be written <syntaxhighlight lang=apl inline>f⍛g</syntaxhighlight>{{←→}}<syntaxhighlight lang=apl inline>f⍛g⍨⍨</syntaxhighlight>{{←→}}<syntaxhighlight lang=apl inline>g⍨∘f⍨</syntaxhighlight>. In [[dzaima/APL]] the monadic case is simply an error.


== Common usage ==
== Common usage ==

Navigation menu