Withe: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (Text replacement - "</source>" to "</syntaxhighlight>")
Tags: Mobile edit Mobile web edit
m (Text replacement - "<source" to "<syntaxhighlight")
Line 1: Line 1:
{{Built-in|Withe|⍩}} is a [[primitive operator]] which forms a [[hook]]. Called [[Dyadic function|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> [[Monadic function|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 [[Monadic function|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.
{{Built-in|Withe|⍩}} is a [[primitive operator]] which forms a [[hook]]. Called [[Dyadic function|dyadically]] with function operands <syntaxhighlight lang=apl inline>f</syntaxhighlight> and <syntaxhighlight lang=apl inline>g</syntaxhighlight>, it uses <syntaxhighlight lang=apl inline>g</syntaxhighlight> [[Monadic function|monadically]] to pre-processes the right argument before applying <syntaxhighlight lang=apl inline>f</syntaxhighlight> to the given left argument and pre-processed right argument. Called [[Monadic function|monadically]] with operands <syntaxhighlight lang=apl inline>f</syntaxhighlight> and <syntaxhighlight lang=apl inline>g</syntaxhighlight>, it uses <syntaxhighlight lang=apl inline>g</syntaxhighlight> monadically to pre-processes the argument before applying <syntaxhighlight 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>.
In usage, <syntaxhighlight lang=apl inline>X f⍩g Y</syntaxhighlight> is equivalent to <syntaxhighlight lang=apl inline>X f g Y</syntaxhighlight>, and <syntaxhighlight lang=apl inline>f⍩g Y</syntaxhighlight> is equivalent to <syntaxhighlight lang=apl inline>Y f g Y</syntaxhighlight>. Thus, Withe can be defined as the [[dop]] <syntaxhighlight lang=apl inline>{⍺←⍵ ⋄ ⍺ ⍺⍺ ⍵⍵ ⍵}</syntaxhighlight> and is equivalent to the [[derived function]] <syntaxhighlight lang=apl inline>f∘g⍨⍨</syntaxhighlight>.


Withe first appeared in [[A Dictionary of APL]],<ref>[[Ken Iverson]]. [[A Dictionary of APL]]. [https://www.jsoftware.com/papers/APLDictionary1.htm#withe Withe]. [[APL Quote Quad]], Volume 18, Number 1, 1987-09.</ref> but substituted by the 2-[[train]] in [[J]] after the proposal in [[Ken Iverson|Iverson]] and [[Eugene McDonnell|McDonnell]]'s paper ''Phrasal Forms''.<ref>[[Ken Iverson]] and [[Eugene McDonnell]]. [http://www.jsoftware.com/papers/fork.htm Phrasal forms] at [[APL89]].</ref> It is present in [[BQN]] as '''After''' (<code>⟜</code>).<ref>[[Marshall Lochbaum]]. ''Tutorial: Combinators''. [https://mlochbaum.github.io/BQN/tutorial/combinator.html#before-and-after Before and After]. Accessed 2021-09-01.</ref>
Withe first appeared in [[A Dictionary of APL]],<ref>[[Ken Iverson]]. [[A Dictionary of APL]]. [https://www.jsoftware.com/papers/APLDictionary1.htm#withe Withe]. [[APL Quote Quad]], Volume 18, Number 1, 1987-09.</ref> but substituted by the 2-[[train]] in [[J]] after the proposal in [[Ken Iverson|Iverson]] and [[Eugene McDonnell|McDonnell]]'s paper ''Phrasal Forms''.<ref>[[Ken Iverson]] and [[Eugene McDonnell]]. [http://www.jsoftware.com/papers/fork.htm Phrasal forms] at [[APL89]].</ref> It is present in [[BQN]] as '''After''' (<code>⟜</code>).<ref>[[Marshall Lochbaum]]. ''Tutorial: Combinators''. [https://mlochbaum.github.io/BQN/tutorial/combinator.html#before-and-after Before and After]. Accessed 2021-09-01.</ref>

Revision as of 10:51, 11 September 2022

Withe () is a primitive operator which forms a hook. Called dyadically with function operands f and g, it uses g monadically to pre-processes the right argument before applying f to the given left argument and pre-processed right argument. Called monadically with operands f and g, it uses g monadically to pre-processes the argument before applying f to the argument and pre-processed argument.

In usage, X f⍩g Y is equivalent to X f g Y, and f⍩g Y is equivalent to Y f g Y. Thus, Withe can be defined as the dop {⍺←⍵ ⋄ ⍺ ⍺⍺ ⍵⍵ ⍵} and is equivalent to the derived function f∘g⍨⍨.

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

  1. Ken Iverson. A Dictionary of APL. Withe. APL Quote Quad, Volume 18, Number 1, 1987-09.
  2. Ken Iverson and Eugene McDonnell. Phrasal forms at APL89.
  3. Marshall Lochbaum. Tutorial: Combinators. Before and After. Accessed 2021-09-01.


APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)
Quad names Index originComparison toleranceMigration levelAtomic vector