Over: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Close composition (SHARP/J) section)
m (Text replacement - "KAP" to "Kap")
 
(9 intermediate revisions by 2 users not shown)
Line 4: Line 4:
When the resulting function is used [[monadic]]ally, it has the same behaviour as if the [[Beside]] or [[Atop (operator)|Atop]] operator had been used:
When the resulting function is used [[monadic]]ally, it has the same behaviour as if the [[Beside]] or [[Atop (operator)|Atop]] operator had been used:
{|
{|
|<source lang=apl>  (g ⍥ h) ⍵</source>|| {{←→}} ||<source lang=apl>g (h ⍵)</source>
|<syntaxhighlight lang=apl>  (g ⍥ h) ⍵</syntaxhighlight>|| {{←→}} ||<syntaxhighlight lang=apl>g (h ⍵)</syntaxhighlight>
|}
|}
When the resulting function is used [[dyadic]]ally, both arguments are pre-processed:
When the resulting function is used [[dyadic]]ally, both arguments are pre-processed:
{|
{|
|<source lang=apl>⍺ (g ⍥ h) ⍵</source>|| {{←→}} ||<source lang=apl>(h ⍺) g (h ⍵)</source>
|<syntaxhighlight lang=apl>⍺ (g ⍥ h) ⍵</syntaxhighlight>|| {{←→}} ||<syntaxhighlight lang=apl>(h ⍺) g (h ⍵)</syntaxhighlight>
|}
|}


== 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 20: Line 20:
       (⌈/x)+⌈/y
       (⌈/x)+⌈/y
9
9
</source>
</syntaxhighlight>


== Close composition ==
== Close composition ==


In [[SHARP APL]] and [[J]], Over 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]], Over is implemented as a [[close composition]], meaning that (using SHARP syntax) <syntaxhighlight lang=apl inline>f⍤g</syntaxhighlight> has the overall [[function rank]] of <syntaxhighlight lang=apl inline>g</syntaxhighlight>. J uses <code>&</code> for the close form and <code>&:</code> for the rankless form that appears in modern APLs.
 
== History ==
 
[[Ken Iverson]] defined Over in 1978 as part of [[Operators and Functions]],<ref>[[Ken Iverson]]. [https://www.jsoftware.com/papers/opfns.htm ''Operators and Functions''], §8 Composition and Duality. IBM Research Report #RC7091. 1978-04-26.</ref> with the glyph <syntaxhighlight lang=apl inline>¨</syntaxhighlight>. 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>⍤</syntaxhighlight> and name "on", 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 glyph <syntaxhighlight lang=apl inline>⍥</syntaxhighlight> appeared in [[NARS2000]], with name "Composition", by 2011.<ref>[http://wiki.nars2000.org/index.php?title=Composition Composition]. [[NARS2000]] Wiki.</ref> The name "Over" was used in [[Dyalog APL 18.0]], suggested by [[Adám Brudzewsky]].<ref>Adam Brudzewsky. Chat message {{m|42021088}}. [[APL Orchard]]. 31 Dec 2017.</ref> Over also appears in [[dzaima/APL]] (since 2018, before Dyalog 18.0), [[April]], and [[Kap]].


== External links ==
== External links ==
Line 32: Line 38:
* [https://help.dyalog.com/latest/#Language/Primitive%20Operators/Over.htm Dyalog]
* [https://help.dyalog.com/latest/#Language/Primitive%20Operators/Over.htm Dyalog]
* J [https://www.jsoftware.com/help/dictionary/d632.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/ampco NuVoc]
* J [https://www.jsoftware.com/help/dictionary/d632.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/ampco NuVoc]
* [https://mlochbaum.github.io/BQN/doc/compose.html BQN]
== References ==
<references/>
{{APL built-ins}}[[Category:Primitive operators]][[Category:Composition operators]]
{{APL built-ins}}[[Category:Primitive operators]][[Category:Composition operators]]

Latest revision as of 21:33, 28 January 2024

Over () is a primitive dyadic operator which takes two function operands and produces a derived function which pre-processes the argument(s) using the monadic right operand, before applying the left operand on/between the result(s).

Explanation

When the resulting function is used monadically, it has the same behaviour as if the Beside or Atop operator had been used:

  (g ⍥ h) ⍵
g (h ⍵)

When the resulting function is used dyadically, both arguments are pre-processed:

⍺ (g ⍥ h) ⍵
(h ⍺) g (h ⍵)

Examples

      x←3 1 2
      y←4 6 5
      x +⍥(⌈/) y ⍝ add the max of x and max of y
9
      ⍝ same as
      (⌈/x)+⌈/y
9

Close composition

In SHARP APL and J, Over is implemented as a close composition, meaning that (using SHARP syntax) f⍤g has the overall function rank of g. J uses & for the close form and &: for the rankless form that appears in modern APLs.

History

Ken Iverson defined Over in 1978 as part of Operators and Functions,[1] with the glyph ¨. He called it Composition, as there was no Atop operator. It was added to SHARP APL as a close composition with glyph and name "on", with a limited implementation in 1981[2] followed by a full implementation in 1983 with the introduction of function rank.[3]

The glyph appeared in NARS2000, with name "Composition", by 2011.[4] The name "Over" was used in Dyalog APL 18.0, suggested by Adám Brudzewsky.[5] Over also appears in dzaima/APL (since 2018, before Dyalog 18.0), April, and Kap.

External links

Lessons

Documentation

References

  1. Ken Iverson. Operators and Functions, §8 Composition and Duality. IBM Research Report #RC7091. 1978-04-26.
  2. "Composition and Enclosure". SATN-41, 1981-06-20.
  3. "Language Extensions of May 1983". SATN-45, 1983-05-02.
  4. Composition. NARS2000 Wiki.
  5. Adam Brudzewsky. Chat message 42021088. APL Orchard. 31 Dec 2017.
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