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
\

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:

      mask1 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]
Primitive functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Selector Index generatorGradeIndex OfInterval IndexIndicesDeal
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Name classCase convertUnicode convert
Operators SearchReplace