Function Composition

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 normal, but in a particular pattern specific to the operator that is being used. The term function composition comes from traditional mathematics, where it is used for a function h(x)=f(g(x)) when written as h(x)=(f∘g)(x) APL generalises this idea to dyadic functions, allowing various patterns of application in addition to the simple application of one monadic function to the result of another monadic function. The four main patterns, represented by atop, behind, beside, and over, can be visualised as shown below.

Information

In the diagrams below, the dotted branch falls away when the operator is applied monadically. Note that monadic atop, beside, and over are all equivalent to each other and to h(x)=(f∘g)(x) of traditional mathematics.

Atop: {R}←{X}f⍤g Y

Function composition diagram for atop
Figure 1: Function composition diagram for atop

Behind: {R}←{X}f⍛g Y

Function composition diagram for monadic behind
Figure 2: Function composition diagram for monadic behind

Function composition diagram for dyadic behind
Figure 3: Function composition diagram for dyadic behind

Beside: {R}←{X}f∘g Y

Function composition diagram for beside
Figure 4: Function composition diagram for beside

Over: {R}←{X}f⍥g Y

Function composition diagram for over
Figure 5: Function composition diagram for over