Atop (operator): Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (→‎Explanation: added missing parenthesis)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 4: Line 4:
When the resulting function is used [[monadic]]ally, it has the same behaviour as if the [[Atop]] 2-train or any of the [[Beside]] or [[Over]] operators had been used:
When the resulting function is used [[monadic]]ally, it has the same behaviour as if the [[Atop]] 2-train or any of the [[Beside]] or [[Over]] operators had been used:
{|
{|
|<source lang=apl>  (g ⍤ h) ⍵</source>|| {{←→}} ||<source lang=apl>g (h ⍵)</source>
|<syntaxhighlight lang=apl>  (g ⍤ h) ⍵</source>|| {{←→}} ||<syntaxhighlight lang=apl>g (h ⍵)</source>
|}
|}
When the resulting function is used [[dyadic]]ally, the result is post-processed:
When the resulting function is used [[dyadic]]ally, the result is post-processed:
{|
{|
|<source lang=apl>⍺ (g ⍤ h) ⍵</source>|| {{←→}} ||<source lang=apl>g (⍺ h ⍵)</source>
|<syntaxhighlight lang=apl>⍺ (g ⍤ h) ⍵</source>|| {{←→}} ||<syntaxhighlight lang=apl>g (⍺ h ⍵)</source>
|}
|}


== Examples ==
== Examples ==
<source lang=apl>
<syntaxhighlight lang=apl>
       x←3 1 2
       x←3 1 2
       y←4 6 5
       y←4 6 5
Line 24: Line 24:
== Close composition ==
== Close composition ==


In [[SHARP APL]] and [[J]], Atop is implemented as a [[close composition]], meaning that (using SHARP syntax) <source lang=apl inline>f⍥g</source> has the overall [[function rank]] of <source lang=apl inline>g</source>. J uses <code>@</code> for the close form and <code>@:</code> for the rankless form that appears in modern APLs.
In [[SHARP APL]] and [[J]], Atop is implemented as a [[close composition]], meaning that (using SHARP syntax) <syntaxhighlight lang=apl inline>f⍥g</source> has the overall [[function rank]] of <syntaxhighlight lang=apl inline>g</source>. J uses <code>@</code> for the close form and <code>@:</code> for the rankless form that appears in modern APLs.


== History ==
== History ==


Atop was defined as subordinate to [[Over]] in [[Ken Iverson]]'s 1978 paper [[Operators and Functions]]: that is, the derived function <source lang=apl inline>f¨g</source> works as an Atop if <source lang=apl inline>f</source> is strictly monadic or (in the dyadic case) <source lang=apl inline>g</source> is strictly dyadic. He called it Composition, as there was no [[Atop operator]]. It was added to [[SHARP APL]] as a [[close composition]] with glyph <source lang=apl inline>⍥</source> and name "upon" (initially "over"), with a limited implementation in 1981<ref>[https://www.jsoftware.com/papers/satn41.htm "Composition and Enclosure"]. SATN-41, 1981-06-20.</ref> followed by a full implementation in 1983 with the introduction of [[function rank]].<ref>[https://www.jsoftware.com/papers/satn45.htm "Language Extensions of May 1983"]. SATN-45, 1983-05-02.</ref> The name "Atop" was introduced by [[J]] (which uses "At" for its non-close form). The glyph <source lang=apl inline>⍤</source> was chosen for [[Dyalog APL 18.0]], shared with the [[Rank operator]].
Atop was defined as subordinate to [[Over]] in [[Ken Iverson]]'s 1978 paper [[Operators and Functions]]: that is, the derived function <syntaxhighlight lang=apl inline>f¨g</source> works as an Atop if <syntaxhighlight lang=apl inline>f</source> is strictly monadic or (in the dyadic case) <syntaxhighlight lang=apl inline>g</source> is strictly dyadic. He called it Composition, as there was no [[Atop operator]]. It was added to [[SHARP APL]] as a [[close composition]] with glyph <syntaxhighlight lang=apl inline>⍥</source> and name "upon" (initially "over"), with a limited implementation in 1981<ref>[https://www.jsoftware.com/papers/satn41.htm "Composition and Enclosure"]. SATN-41, 1981-06-20.</ref> followed by a full implementation in 1983 with the introduction of [[function rank]].<ref>[https://www.jsoftware.com/papers/satn45.htm "Language Extensions of May 1983"]. SATN-45, 1983-05-02.</ref> The name "Atop" was introduced by [[J]] (which uses "At" for its non-close form). The glyph <syntaxhighlight lang=apl inline>⍤</source> was chosen for [[Dyalog APL 18.0]], shared with the [[Rank operator]].


== External links ==
== External links ==

Revision as of 21:11, 10 September 2022

Atop () is a primitive dyadic operator which takes two function operands and produces a derived function which uses the left operand monadically to post-processes the result of the ambivalent right operand.

Explanation

When the resulting function is used monadically, it has the same behaviour as if the Atop 2-train or any of the Beside or Over operators had been used:

<syntaxhighlight lang=apl> (g ⍤ h) ⍵</source> <syntaxhighlight lang=apl>g (h ⍵)</source>

When the resulting function is used dyadically, the result is post-processed:

<syntaxhighlight lang=apl>⍺ (g ⍤ h) ⍵</source> <syntaxhighlight lang=apl>g (⍺ h ⍵)</source>

Examples

<syntaxhighlight lang=apl>

     x←3 1 2
     y←4 6 5
     x -⍤⌈ y ⍝ the negation of the max of x y

¯4 ¯6 ¯5

     ⍝ same as
     -x⌈y

¯4 ¯6 ¯5 </source>

Close composition

In SHARP APL and J, Atop is implemented as a close composition, meaning that (using SHARP syntax) <syntaxhighlight lang=apl inline>f⍥g</source> has the overall function rank of <syntaxhighlight lang=apl inline>g</source>. J uses @ for the close form and @: for the rankless form that appears in modern APLs.

History

Atop was defined as subordinate to Over in Ken Iverson's 1978 paper Operators and Functions: that is, the derived function <syntaxhighlight lang=apl inline>f¨g</source> works as an Atop if <syntaxhighlight lang=apl inline>f</source> is strictly monadic or (in the dyadic case) <syntaxhighlight lang=apl inline>g</source> is strictly dyadic. He called it Composition, as there was no Atop operator. It was added to SHARP APL as a close composition with glyph <syntaxhighlight lang=apl inline>⍥</source> and name "upon" (initially "over"), with a limited implementation in 1981[1] followed by a full implementation in 1983 with the introduction of function rank.[2] The name "Atop" was introduced by J (which uses "At" for its non-close form). The glyph <syntaxhighlight lang=apl inline>⍤</source> was chosen for Dyalog APL 18.0, shared with the Rank operator.

External links

Lessons

Documentation

APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare RootRound
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 axisIdentity (Null, Ident)
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)Identity (Lev, Dex)
Quad names Index originComparison toleranceMigration levelAtomic vector
  1. "Composition and Enclosure". SATN-41, 1981-06-20.
  2. "Language Extensions of May 1983". SATN-45, 1983-05-02.