Singleton: Difference between revisions

Jump to navigation Jump to search
99 bytes added ,  11:00, 11 September 2022
m
Text replacement - "</source>" to "</syntaxhighlight>"
m (Text replacement - "<source" to "<syntaxhighlight")
m (Text replacement - "</source>" to "</syntaxhighlight>")
Tags: Mobile edit Mobile web edit
 
Line 1: Line 1:
A '''singleton''' is an [[Array model|array]] with [[bound]] 1. Equivalently, its [[shape]] consists entirely of 1s. It may have any [[rank]]. For example, all the following are singletons:
A '''singleton''' is an [[Array model|array]] with [[bound]] 1. Equivalently, its [[shape]] consists entirely of 1s. It may have any [[rank]]. For example, all the following are singletons:


* The [[scalar]] <syntaxhighlight lang=apl inline>42</source>
* The [[scalar]] <syntaxhighlight lang=apl inline>42</syntaxhighlight>
* The [[vector]] <syntaxhighlight lang=apl inline>,42</source>
* The [[vector]] <syntaxhighlight lang=apl inline>,42</syntaxhighlight>
* The [[matrix]] <syntaxhighlight lang=apl inline>⍪42</source>
* The [[matrix]] <syntaxhighlight lang=apl inline>⍪42</syntaxhighlight>
* The three-[[dimension]]al array <syntaxhighlight lang=apl inline>1 1 1⍴42</source>
* The three-[[dimension]]al array <syntaxhighlight lang=apl inline>1 1 1⍴42</syntaxhighlight>
* The [[nested]] scalar <syntaxhighlight lang=apl inline>⊂4 2</source>
* The [[nested]] scalar <syntaxhighlight lang=apl inline>⊂4 2</syntaxhighlight>


Whether an array <syntaxhighlight lang=apl inline>X</source> is a singleton can be determined with <syntaxhighlight lang=apl inline>1=×/⍴X</source> or, less efficiently, with <syntaxhighlight lang=apl inline>1=≢,X</source>.
Whether an array <syntaxhighlight lang=apl inline>X</syntaxhighlight> is a singleton can be determined with <syntaxhighlight lang=apl inline>1=×/⍴X</syntaxhighlight> or, less efficiently, with <syntaxhighlight lang=apl inline>1=≢,X</syntaxhighlight>.


Every scalar <syntaxhighlight lang=apl inline>X</source> is a singleton, because <syntaxhighlight lang=apl inline>1=×/⍴X</source>, or alternatively <syntaxhighlight lang=apl inline>1=≢,X</source>.
Every scalar <syntaxhighlight lang=apl inline>X</syntaxhighlight> is a singleton, because <syntaxhighlight lang=apl inline>1=×/⍴X</syntaxhighlight>, or alternatively <syntaxhighlight lang=apl inline>1=≢,X</syntaxhighlight>.


Singletons may be subject to [[singleton extension]].
Singletons may be subject to [[singleton extension]].

Navigation menu