Reverse Compose: Difference between revisions

Jump to navigation Jump to search
119 bytes added ,  09:04, 23 May 2022
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
{{Built-in|Reverse Compose|⍛}}, also known as '''Before''', is a [[primitive operator]] closely related to [[Beside]] (<source lang=apl inline>∘</source>), also known as ''After''. Called [[dyad|dyadically]] with function operands <source lang=apl inline>f</source> and <source lang=apl inline>g</source>, it uses <source lang=apl inline>f</source> [[monad|monadically]] to pre-processes the left argument before applying <source lang=apl inline>g</source> between the pre-processed 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>.
{{Built-in|Reverse Compose|⍛}}, also known as '''Before''', is a [[primitive operator]] closely related to [[Beside]] (<source lang=apl inline>∘</source>), also known as ''After''. Called [[dyad|dyadically]] with function operands <source lang=apl inline>f</source> and <source lang=apl inline>g</source>, it uses <source lang=apl inline>f</source> [[monad|monadically]] to pre-processes the left argument before applying <source lang=apl inline>g</source> between the pre-processed 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 [[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. The [[monadic]] case was discussed for a while in the [[APL Orchard]]. To be completely consistent with the other [[compositional operators|function composition]], the left "leg" would be removed, making <source lang=apl inline>f⍛g Y</source> be equivalent to <source lang=apl inline>g Y</source>. However, this would never apply <source lang=apl inline>f</source> and would questionably be called a ''composition'' of <source lang=apl inline>f</source> and <source lang=apl inline>g</source>. Instead, it was concluded that the best solution would be to have <source lang=apl inline>f⍛g Y</source> be a [[hook]], <source lang=apl inline>f⍛g⍨Y</source>, that is, <source lang=apl inline>f⍛g</source>{{←→}}<source lang=apl inline>f⍛g⍨⍨</source>{{←→}}<source lang=apl inline>g⍨∘f⍨</source>.
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. The [[monadic]] case was discussed for a while in the [[APL Orchard]].<ref>[[Adám Brudzewsky]]. Message {{M|60006135}}ff. [[APL Orchard]]. 29 Dec 2021.</ref> To be completely consistent with the other [[compositional operators|function composition]], the left "leg" would be removed, making <source lang=apl inline>f⍛g Y</source> be equivalent to <source lang=apl inline>g Y</source>. However, this would never apply <source lang=apl inline>f</source> and would questionably be called a ''composition'' of <source lang=apl inline>f</source> and <source lang=apl inline>g</source>. Instead, it was concluded that the best solution would be to have <source lang=apl inline>f⍛g Y</source> be a [[hook]], <source lang=apl inline>f⍛g⍨Y</source>, that is, <source lang=apl inline>f⍛g</source>{{←→}}<source lang=apl inline>f⍛g⍨⍨</source>{{←→}}<source lang=apl inline>g⍨∘f⍨</source>.


== Common usage ==
== Common usage ==
Line 16: Line 16:
2 ¯7 1
2 ¯7 1
</source>{{Works in|[[dzaima/APL]], [[Extended Dyalog APL]]}}
</source>{{Works in|[[dzaima/APL]], [[Extended Dyalog APL]]}}
== References ==
<references/>
{{APL built-ins}}[[Category:Primitive operators]][[Category:Composition operators]]
{{APL built-ins}}[[Category:Primitive operators]][[Category:Composition operators]]

Navigation menu