4,494
edits
(Created page with "'''Function composition''' refers to the "gluing" together of two functions using a dyadic operator such that the functions are applied to the argument(s) as norma...") |
|||
Line 10: | Line 10: | ||
Of note is [[Reverse-compose]] <source lang=apl inline>⍛</source> (also called ''Before''), which is the mirrored version of Beside <source lang=apl inline>∘</source> (also known as ''Compose'' and ''After''), because it is the only such variation that has been implemented, namely in [[dzaima/APL]] and [[Extended Dyalog APL]]. | Of note is [[Reverse-compose]] <source lang=apl inline>⍛</source> (also called ''Before''), which is the mirrored version of Beside <source lang=apl inline>∘</source> (also known as ''Compose'' and ''After''), because it is the only such variation that has been implemented, namely in [[dzaima/APL]] and [[Extended Dyalog APL]]. | ||
A compositional operator that isn't just a shuffled around version of the basic three, is one that applies one operand between the other operand's dyadic result and the result of that other | A compositional operator that isn't just a shuffled around version of the basic three, is one that applies one operand between the other operand's dyadic result and the result of that other operand's result when [[swap]]ped: <source lang=apl inline>{(⍵ ⍵⍵ ⍺) ⍺⍺ (⍺ ⍵⍵ ⍵)}</source>. This operator can for example be used to implement [[wikipedia:three-way comparison|three-way comparison]]: | ||
[https://tio.run/##SyzI0U2pTMzJT///P1jhUdsEhWqNR71bFYAYQu3SBBFApKABIuDiWzVruZJzC8BadIMfdS7hetQ3FcQxUjBWMFEASRn//w8A Try it online!]<source lang=apl> | [https://tio.run/##SyzI0U2pTMzJT///P1jhUdsEhWqNR71bFYAYQu3SBBFApKABIuDiWzVruZJzC8BadIMfdS7hetQ3FcQxUjBWMFEASRn//w8A Try it online!]<source lang=apl> | ||
S ← {(⍵ ⍵⍵ ⍺) ⍺⍺ (⍺ ⍵⍵ ⍵)} | S ← {(⍵ ⍵⍵ ⍺) ⍺⍺ (⍺ ⍵⍵ ⍵)} |