Reverse Compose: Difference between revisions
No edit summary 
mNo edit summary 

Line 1:  Line 1:  
{{BuiltinReverse Compose⍛}}, also known as '''Before''', is a [[primitive operator]] closely related to [[Beside]] (<source lang=apl inline>∘</source>), also known as ''After''. Called [[dyaddyadically]] with function operands <source lang=apl inline>f</source> and <source lang=apl inline>g</source>, it uses <source lang=apl inline>f</source> [[monadmonadically]] to preprocesses the left argument before applying <source lang=apl inline>g</source> between the preprocessed left argument and the given right argument. <source lang=apl inline>X f⍛g Y</source> is thus equivalent to <source lang=apl inline>(f X) g Y</source>. The operator can be defined as the [[dop]] <source lang=apl inline>{(⍺⍺ ⍺) ⍵⍵ ⍵}</source>.  {{BuiltinReverse Compose⍛}}, also known as '''Before''', is a [[primitive operator]] closely related to [[Beside]] (<source lang=apl inline>∘</source>), also known as ''After''. Called [[dyaddyadically]] with function operands <source lang=apl inline>f</source> and <source lang=apl inline>g</source>, it uses <source lang=apl inline>f</source> [[monadmonadically]] to preprocesses the left argument before applying <source lang=apl inline>g</source> between the preprocessed left argument and the given right argument. <source lang=apl inline>X f⍛g Y</source> is thus equivalent to <source lang=apl inline>(f X) g Y</source>. The operator can be defined as the [[dop]] <source lang=apl inline>{(⍺⍺ ⍺) ⍵⍵ ⍵}</source>.  
Reverse compose was introduced in [[Extended Dyalog APL]], and then adopted into [[dzaima/APL]]. Its [[dyadic]] case matches  Reverse compose was introduced in [[Extended Dyalog APL]], and then adopted into [[dzaima/APL]]. Its [[dyadic]] case matches [[I]]'s Hook (<code>h</code>), which is a reflected form of a [[J]] [[Hook]], while Backhook (<code>H</code>) matches the ordinary [[Hook]] or [[Compose]]: because I's [[precedence]] order is left to right, it considers the "reversed" APL form to be primary.  
== Common usage ==  == Common usage == 
Revision as of 09:59, 10 March 2021
⍛

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 preprocesses the left argument before applying g
between the preprocessed 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.
Common usage
Its plain usage is to preprocess 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:
3×⍨⍛2 7
It can also be combined with Beside to create the splitcompose construct. Here, we take the sign of the left argument and apply it to the absolute value of the right argument:
3 ¯1 4×⍛×∘¯2 ¯7 1 2 ¯7 1