Scan

From APL Wiki
Revision as of 12:47, 9 September 2021 by Hou32hou (talk | contribs) (Created page with "{{Built-in|Scan|<nowiki>\</nowiki>}} is a monadic operator which takes a dyadic functions and produce a monadic function (<source lang=apl inline>\</source>). ==...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
\

Scan (\) is a monadic operator which takes a dyadic functions and produce a monadic function (\).

Explanation

Scan is similar to Reduce, however all the intermediate results will be retained. That being said, unlike Reduce, Scan does not reduce the number of elements, i.e. performing Scan over a 10-elements array will produce a 10-elements array.

Examples

      +\⍳5 ⍝ plus-scan over range of integer from 1 to 5
1 3 6 10 15

Applications

Removing disconnected trailing 1s from a boolean mask:

      mask←1 1 1 1 0 1 1 0 0 1
      mask
1 1 1 1 0 1 1 0 0 1
      ∧\mask ⍝ and-scan mask
1 1 1 1 0 0 0 0 0 0
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