Type

From APL Wiki
Jump to navigation Jump to search

Type (, , ) is a monadic scalar function which in the nested array model gives information about the type and structure of its argument array's elements. In normal cases, the result is identical to the argument, with all numbers replaced by zeros and all characters replaced by spaces, and the substitution is done recursively.

Support

Few dialects have Type as a primitive function. Dyalog APL uses (as in prototypical element), but only when migration level is 0, while NARS2000 uses monadic (resembling the Latin letter T for Type), which it inherited from NARS. Extended Dyalog APL uses monadic with the underscore indicating functionality of the corresponding non-underscored glyph from a non-default migration level.[1]

However, in all dialects that support nested arrays, the type can be determined by enclosing/boxing the array in an empty array, and then coercing out a fill value. Since the array prototype is used as fill element, the resulting array will be the type of the original array:

       0   1 2 'ab'
┌─┬─┬──┐
00  
└─┴─┴──┘
Works in: Dyalog APL with migration level≥2, APL2, APLX
       0   1 2 'ab'
┌─┬─┬──┐
00  
└─┴─┴──┘
Works in: Dyalog APL with migration level=1

External links

Documentation

References

  1. Partition is with migration level≤2 while the original glyph is as with migration level 3. Dyalog Language Reference Guide: Left Shoe.
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, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Case convertUnicode convert
Operators SearchReplace