Zilde: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
No edit summary
(fix examples)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Built-in|Zilde|⍬}} or '''Zero-tilde''' (which the common name is a portmanteau of), is the [[empty]] [[numeric]] [[vector]]. It is the [[shape]] of any [[scalar]], although its own shape is <source lang=apl inline>,0</source>. This is because, as a vector, it has exactly one [[axis]], and this axis has length 0. Zilde is equivalent to <source lang=apl inline>⍳0</source> and <source lang=apl inline>⍴0</source> and <source lang=apl inline>0⍴0</source>. Being [[numeric]], Zilde's [[prototype]] is 0.
{{Built-in|Zilde|⍬}}, or '''Zero-tilde''' (which the common name is a portmanteau of), is the [[empty]] [[numeric]] [[vector]]. It shares its name with the [[glyph]] used to represent it, a zero [[overstrike|overstruck]] with a tilde. It is the [[shape]] of any [[scalar]], although its own shape is <syntaxhighlight lang=apl inline>,0</syntaxhighlight>. This is because, as a vector, it has exactly one [[axis]], and this axis has length 0. Zilde is equivalent to <syntaxhighlight lang=apl inline>⍳0</syntaxhighlight> and <syntaxhighlight lang=apl inline>⍴0</syntaxhighlight> and <syntaxhighlight lang=apl inline>0⍴0</syntaxhighlight>. Being [[numeric]], Zilde's [[prototype]] is 0.


Zilde is notable for being an APL [[glyph]] which represents an array rather than a [[primitive function]] or [[primitive operator]]. In most APLs it is the only array literal which is produced using its own token rather than being part of a family of array literals like [[numeric literal]]s, [[string]]s, or [[system constant]]s (an exception is [[SHARP APL]]'s [[nil]] (<source lang=apl inline>∘</source>), which is the same as <source lang=apl inline>⊂⍬</source>).
The [[glyph]] Zilde is notable in that it represents an array rather than a [[primitive function]] or [[primitive operator]]. This usage was introduced in [[NARS]] and included in [[Dyalog APL]] and many other dialects influenced by these. In most of these APLs it is the only array literal which is produced using its own token rather than being part of a family of array literals like [[numeric literal]]s, [[string]]s, or [[system constant]]s. A similar special literal is [[SHARP APL]]'s [[nil]] (<syntaxhighlight lang=apl inline>∘</syntaxhighlight>), which corresponds to <syntaxhighlight lang=apl inline>⊂⍬</syntaxhighlight>, and Dyalog APL's [[namespace]] reference to the root of the [[workspace]] (<syntaxhighlight lang=apl inline>#</syntaxhighlight>).


It should be noted that the empty numeric vector (<source lang=apl inline>⍬</source>) is distinct from the empty character vector (<source lang=apl inline>''</source>) even though they have the same shape and the same elements:
It should be noted that the empty numeric vector (<syntaxhighlight lang=apl inline>⍬</syntaxhighlight>) is distinct from the empty character vector (<syntaxhighlight lang=apl inline>''</syntaxhighlight>) even though they have the same shape and the same elements:
<source lang=apl>
<syntaxhighlight lang=apl>
       ∧/⍬=''
       ∧/⍬=''
1
1
       ⍬≡''
       ⍬≡''
0
0
</source>
</syntaxhighlight>
This is because <source lang=apl inline>⍬=''</source> itself returns an empty numeric vector, and reducing an empty vector with the [[Logical And]] function (<source lang=apl inline>∧</source>) yields the [[identity element]] of Logical And, which is 1. However, [[match]] takes [[empty]] array [[prototype]]s into account as well as shapes and elements, so it indicates that the arrays are different.
This is because <syntaxhighlight lang=apl inline>⍬=''</syntaxhighlight> itself returns an empty numeric vector, and reducing an empty vector with the [[Logical And]] function (<syntaxhighlight lang=apl inline>∧</syntaxhighlight>) yields the [[identity element]] of Logical And, which is 1. However, [[match]] takes [[empty]] array [[prototype]]s into account as well as shapes and elements, so it indicates that the arrays are different.


Zilde can be used to concisely produce other empty arrays, for example:
Zilde can be used to concisely produce other empty arrays, for example:


* <source lang=apl inline>⍬⊤⍬</source> gives a 0-row 0-column numeric matrix, identical to <source lang=apl inline>0 0⍴0</source>.
* <syntaxhighlight lang=apl inline>⍬⊤⍬</syntaxhighlight> gives a 0-row 0-column numeric matrix, identical to <syntaxhighlight lang=apl inline>0 0⍴0</syntaxhighlight>.
* <source lang=apl inline>⍪⍬</source> gives a 0-row 0-column numeric matrix, identical to <source lang=apl inline>0 1⍴0</source>.
* <syntaxhighlight lang=apl inline>⍪⍬</syntaxhighlight> gives a 0-row 1-column numeric matrix, identical to <syntaxhighlight lang=apl inline>0 1⍴0</syntaxhighlight>.
* <source lang=apl inline>,¨⍬</source> gives an empty vector of 1-element numeric vectors, identical to <source lang=apl inline>0⍴⊂,0</source>.
* <syntaxhighlight lang=apl inline>⍉⍪⍬</syntaxhighlight> gives a 1-row 0-column numeric matrix, identical to <syntaxhighlight lang=apl inline>1 0⍴0</syntaxhighlight>.
* <source lang=apl inline>⍪¨⍬</source> gives an empty vector of 1-by-1 numeric matrices, identical to <source lang=apl inline>0⍴⊂,0</source>.
* <syntaxhighlight lang=apl inline>,¨⍬</syntaxhighlight> gives an empty vector of 1-element numeric vectors, identical to <syntaxhighlight lang=apl inline>0⍴⊂,0</syntaxhighlight>.
{{APL glyphs}}[[Category:Primitive arrays]]
* <syntaxhighlight lang=apl inline>⍪¨⍬</syntaxhighlight> gives an empty vector of 1-by-1 numeric matrices, identical to <syntaxhighlight lang=apl inline>0⍴⊂⍪0</syntaxhighlight>.
{{APL built-ins}}{{APL glyphs}}[[Category:Primitive arrays]][[Category:Glyphs]]

Latest revision as of 08:12, 6 October 2022

Zilde (), or Zero-tilde (which the common name is a portmanteau of), is the empty numeric vector. It shares its name with the glyph used to represent it, a zero overstruck with a tilde. It is the shape of any scalar, although its own shape is ,0. This is because, as a vector, it has exactly one axis, and this axis has length 0. Zilde is equivalent to ⍳0 and ⍴0 and 0⍴0. Being numeric, Zilde's prototype is 0.

The glyph Zilde is notable in that it represents an array rather than a primitive function or primitive operator. This usage was introduced in NARS and included in Dyalog APL and many other dialects influenced by these. In most of these APLs it is the only array literal which is produced using its own token rather than being part of a family of array literals like numeric literals, strings, or system constants. A similar special literal is SHARP APL's nil (), which corresponds to ⊂⍬, and Dyalog APL's namespace reference to the root of the workspace (#).

It should be noted that the empty numeric vector () is distinct from the empty character vector ('') even though they have the same shape and the same elements:

      ∧/⍬=''
1
      ⍬≡''
0

This is because ⍬='' itself returns an empty numeric vector, and reducing an empty vector with the Logical And function () yields the identity element of Logical And, which is 1. However, match takes empty array prototypes into account as well as shapes and elements, so it indicates that the arrays are different.

Zilde can be used to concisely produce other empty arrays, for example:

  • ⍬⊤⍬ gives a 0-row 0-column numeric matrix, identical to 0 0⍴0.
  • ⍪⍬ gives a 0-row 1-column numeric matrix, identical to 0 1⍴0.
  • ⍉⍪⍬ gives a 1-row 0-column numeric matrix, identical to 1 0⍴0.
  • ,¨⍬ gives an empty vector of 1-element numeric vectors, identical to 0⍴⊂,0.
  • ⍪¨⍬ gives an empty vector of 1-by-1 numeric matrices, identical to 0⍴⊂⍪0.
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
APL glyphs [edit]
Information GlyphTyping glyphs (on Linux) ∙ UnicodeFontsMnemonicsOverstrikesMigration level
Individual glyphs Jot () ∙ Right Shoe () ∙ Up Arrow () ∙ Zilde () ∙ High minus (¯) ∙ Dot (.) ∙ Del ()