Over: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(direct link)
(Close composition (SHARP/J) section)
Line 21: Line 21:
9
9
</source>
</source>
== 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.
== External links ==
== External links ==
=== Lessons ===
=== Lessons ===

Revision as of 17:24, 25 April 2022

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.

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