Materialise: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Created page with "{{Built-in|Materialise|⌷}} is a monadic primitive function which tries to cast the argument (which can be any object) into an APL array. If the argument is alrea...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
Line 1: Line 1:
{{Built-in|Materialise|⌷}} is a [[monadic]] [[primitive function]] which tries to cast the [[argument]] (which can be any object) into an APL array. If the argument is already an array, it is returned unmodified. It is only available in [[Dyalog APL]], which supports classes and .NET objects. Materialise shares its [[glyph]] <source lang=apl inline>⌷</source> with [[Index (function)|Index]].
{{Built-in|Materialise|⌷}} is a [[monadic]] [[primitive function]] which tries to cast the [[argument]] (which can be any object) into an APL array. If the argument is already an array, it is returned unmodified. It is only available in [[Dyalog APL]], which supports classes and .NET objects. Materialise shares its [[glyph]] <source lang=apl inline>⌷</syntaxhighlight> with [[Index (function)|Index]].


== Examples ==
== Examples ==
Line 14: Line 14:
     :EndProperty
     :EndProperty
:EndClass
:EndClass
</source>{{Works in|[[Dyalog APL]]}}
</syntaxhighlight>{{Works in|[[Dyalog APL]]}}


If one property is declared as default, Materialise returns the value of the default property.
If one property is declared as default, Materialise returns the value of the default property.
Line 25: Line 25:
       cl.thing  ⍝ Actual effect of the line above
       cl.thing  ⍝ Actual effect of the line above
3 1 4 1 4
3 1 4 1 4
</source>{{Works in|[[Dyalog APL]]}}
</syntaxhighlight>{{Works in|[[Dyalog APL]]}}


Materialise can also be used on a .NET collection, which returns the underlying array of data.
Materialise can also be used on a .NET collection, which returns the underlying array of data.
Line 35: Line 35:
       ⍴⌷ba  ⍝ but it is actually a container of 5 values
       ⍴⌷ba  ⍝ but it is actually a container of 5 values
5
5
</source>{{Works in|[[Dyalog APL]]}}
</syntaxhighlight>{{Works in|[[Dyalog APL]]}}


Materialise is the same as [[Identity]] for APL arrays.
Materialise is the same as [[Identity]] for APL arrays.
Line 42: Line 42:
       (⌷≡⊢) 1 2 3 4 5
       (⌷≡⊢) 1 2 3 4 5
1
1
</source>{{Works in|[[Dyalog APL]]}}
</syntaxhighlight>{{Works in|[[Dyalog APL]]}}


== External links ==
== External links ==

Revision as of 20:57, 10 September 2022

Materialise () is a monadic primitive function which tries to cast the argument (which can be any object) into an APL array. If the argument is already an array, it is returned unmodified. It is only available in Dyalog APL, which supports classes and .NET objects. Materialise shares its glyph <source lang=apl inline>⌷</syntaxhighlight> with Index.

Examples

Dyalog APL allows the user to define a class, which looks like the following:

<source lang=apl>

Class cl
   :Property Default thing
   :Access Public Shared
       ∇ r←get
         r←3 1 4 1 4
       ∇
   :EndProperty
EndClass

</syntaxhighlight>

Works in: Dyalog APL

If one property is declared as default, Materialise returns the value of the default property.

<source lang=apl>

     ⊢cl  ⍝ It is an object
  1. .cl
     ⌷cl  ⍝ ⌷ casts cl to an array by getting the default property

3 1 4 1 4

     cl.thing  ⍝ Actual effect of the line above

3 1 4 1 4

</syntaxhighlight>

Works in: Dyalog APL

Materialise can also be used on a .NET collection, which returns the underlying array of data.

<source lang=apl>

     ba←⎕NEW System.Collections.BitArray(⊂1 0 1 1 0)
     ⍬≡⍴ba  ⍝ ba itself is a scalar object

1

     ⍴⌷ba  ⍝ but it is actually a container of 5 values

5

</syntaxhighlight>

Works in: Dyalog APL

Materialise is the same as Identity for APL arrays.

<source lang=apl>

     (⌷≡⊢) 1 2 3 4 5

1

</syntaxhighlight>

Works in: Dyalog APL

External links

Tutorials

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