Singleton: Difference between revisions

Jump to navigation Jump to search
707 bytes added ,  08:57, 13 May 2020
m
no edit summary
Miraheze>Marshall
mNo edit summary
mNo edit summary
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
A '''singleton''' is an array with [[bound]] 1. Equivalently, its [[shape]] consists entirely of 1s. It may have any [[rank]].
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:


Every [[scalar]] is a singleton, because <source lang=apl inline>1=×/</source>.
* The [[scalar]] <source lang=apl inline>42</source>
* The [[vector]] <source lang=apl inline>,42</source>
* The [[matrix]] <source lang=apl inline>⍪42</source>
* The three-[[dimension]]al array <source lang=apl inline>1 1 1⍴42</source>
* The [[nested]] scalar <source lang=apl inline>⊂4 2</source>
 
Whether an array <source lang=apl inline>X</source> is a singleton can be determined with <source lang=apl inline>1=×/⍴X</source> or, less efficiently, with <source lang=apl inline>1=≢,X</source>.
 
Every scalar <source lang=apl inline>X</source> is a singleton, because <source lang=apl inline>1=×/⍴X</source>, or alternatively <source lang=apl inline>1=≢,X</source>.


Singletons may be subject to [[singleton extension]].
Singletons may be subject to [[singleton extension]].
{{APL features}}[[Category:Kinds of array]]

Navigation menu