# Singleton: Difference between revisions

Jump to navigation
Jump to search

m (4 revisions imported: Migrate from miraheze) |
No edit summary |
||

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]] with [[bound]] 1. Equivalently, its [[shape]] consists entirely of 1s. It may have any [[rank]]. For example, all the following are singletons: | ||

* 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}} |

## Revision as of 11:07, 26 December 2019

A **singleton** is an 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
`42`

- The vector
`,42`

- The matrix
`⍪42`

- The three-dimensional array
`1 1 1⍴42`

- The nested scalar
`⊂4 2`

Whether an array `X`

is a singleton can be determined with `1=×/⍴X`

or, less efficiently, with `1=≢,X`

.

Every scalar `X`

is a singleton, because `1=×/⍴X`

, or alternatively `1=≢,X`

.

Singletons may be subject to singleton extension.

APL features [edit]
| |
---|---|

Built-ins | Primitives (functions, operators) ∙ Quad name |

Array model | Shape ∙ Rank ∙ Depth ∙ Bound ∙ Index (Indexing) ∙ Axis ∙ Ravel ∙ Ravel order ∙ Element ∙ Scalar ∙ Vector ∙ Matrix ∙ Simple scalar ∙ Simple array ∙ Nested array ∙ Cell ∙ Major cell ∙ Subarray ∙ Empty array ∙ Prototype |

Data types | Number (Boolean, Complex number) ∙ Character (String) ∙ Box ∙ Namespace ∙ Function array |

Concepts and paradigms | Conformability (Scalar extension, Leading axis agreement) ∙ Scalar function (Pervasion) ∙ Identity element ∙ Complex floor ∙ Total array ordering ∙ Tacit programming (Function composition, Close composition) ∙ Glyph |

Errors | LIMIT ERROR ∙ RANK ERROR ∙ SYNTAX ERROR ∙ DOMAIN ERROR ∙ LENGTH ERROR ∙ INDEX ERROR ∙ VALUE ERROR |