Split composition: Difference between revisions

Jump to navigation Jump to search
5 bytes removed ,  12:19, 20 September 2022
m
no edit summary
m (Faun Locke moved page Split-compose to Split composition: Generalizing the topic)
mNo edit summary
Line 1: Line 1:
'''Split composition''' is a [[tacit]] pattern, used to pre-process argument(s) with the outer-most operands before applying the middle operand between the result. Given functions <syntaxhighlight lang=apl inline>f</syntaxhighlight>, <syntaxhighlight lang=apl inline>g</syntaxhighlight>, and <syntaxhighlight lang=apl inline>h</syntaxhighlight>, the split composition on arguments <syntaxhighlight lang=apl inline>x</syntaxhighlight> and <syntaxhighlight lang=apl inline>y</syntaxhighlight> is defined as <syntaxhighlight lang=apl inline>(f x) g (h y)</syntaxhighlight>.
'''Split composition''' is a [[tacit]] pattern, used to pre-process argument(s) with the outer-most operands before applying the middle operand between the result. Given functions <syntaxhighlight lang=apl inline>f</syntaxhighlight>, <syntaxhighlight lang=apl inline>g</syntaxhighlight>, and <syntaxhighlight lang=apl inline>h</syntaxhighlight>, a split composition on arguments <syntaxhighlight lang=apl inline>x</syntaxhighlight> and <syntaxhighlight lang=apl inline>y</syntaxhighlight> is defined as <syntaxhighlight lang=apl inline>(f x) g (h y)</syntaxhighlight>.


This construct was introduced by the [[I|I language]] as "split-compose", where it is represented with <syntaxhighlight lang=apl inline>O</syntaxhighlight>. <syntaxhighlight lang=apl inline>O</syntaxhighlight> also represents the [[Over]] operator, as it is a split composition with identical outer operands.  
This construct was introduced by the [[I|I language]] as "split-compose", where it is represented with <syntaxhighlight lang=apl inline>O</syntaxhighlight>. <syntaxhighlight lang=apl inline>O</syntaxhighlight> also represents the [[Over]] operator, as it is a split composition with identical outer operands.  
Line 18: Line 18:
== Alternatives ==
== Alternatives ==


In dialects that lack Reverse Compose (and even Compose), split compositions can be denoted either by defining the missing operator(s), or as a single derived function or [[fork]], if this is supported. For example, in [[Dyalog APL]] the expression can be formed with Compose and [[Commute]] (<syntaxhighlight lang=apl inline>⍨</syntaxhighlight>) as <syntaxhighlight lang=apl inline>g⍨∘f⍨∘h</syntaxhighlight>:
In dialects that lack Reverse Compose (and even Compose), split compositions can be denoted either by defining the missing operator(s), or as a single derived function or [[fork]], if this is supported. For example, in [[Dyalog APL]] the pattern can be formed with Compose and [[Commute]] (<syntaxhighlight lang=apl inline>⍨</syntaxhighlight>) as <syntaxhighlight lang=apl inline>g⍨∘f⍨∘h</syntaxhighlight>:
<syntaxhighlight lang=apl>
<syntaxhighlight lang=apl>
       5 ×⍨∘⍳⍨∘| 5 ¯8 ¯2 ¯5 3
       5 ×⍨∘⍳⍨∘| 5 ¯8 ¯2 ¯5 3
26

edits

Navigation menu