Withe
Withe (⍩
) is a primitive operator which forms a hook. Called dyadically with function operands <source lang=apl inline>f</syntaxhighlight> and <source lang=apl inline>g</syntaxhighlight>, it uses <source lang=apl inline>g</syntaxhighlight> monadically to pre-processes the right argument before applying <source lang=apl inline>f</syntaxhighlight> to the given left argument and pre-processed right argument. Called monadically with operands <source lang=apl inline>f</syntaxhighlight> and <source lang=apl inline>g</syntaxhighlight>, it uses <source lang=apl inline>g</syntaxhighlight> monadically to pre-processes the argument before applying <source lang=apl inline>f</syntaxhighlight> to the argument and pre-processed argument.
In usage, <source lang=apl inline>X f⍩g Y</syntaxhighlight> is equivalent to <source lang=apl inline>X f g Y</syntaxhighlight>, and <source lang=apl inline>f⍩g Y</syntaxhighlight> is equivalent to <source lang=apl inline>Y f g Y</syntaxhighlight>. Thus, Withe can be defined as the dop <source lang=apl inline>{⍺←⍵ ⋄ ⍺ ⍺⍺ ⍵⍵ ⍵}</syntaxhighlight> and is equivalent to the derived function <source lang=apl inline>f∘g⍨⍨</syntaxhighlight>.
Withe first appeared in A Dictionary of APL,[1] but substituted by the 2-train in J after the proposal in Iverson and McDonnell's paper Phrasal Forms.[2] It is present in BQN as After (⟜
).[3]
See also
References
- ↑ Ken Iverson. A Dictionary of APL. Withe. APL Quote Quad, Volume 18, Number 1, 1987-09.
- ↑ Ken Iverson and Eugene McDonnell. Phrasal forms at APL89.
- ↑ Marshall Lochbaum. Tutorial: Combinators. Before and After. Accessed 2021-09-01.