listOf1
listOf1 is a term used in programming to denote a function or constructor that creates a list containing exactly one element. The idea is to produce a singleton list: a list whose length is one and whose only item is the provided value. The name listOf1 is not universal, but the concept appears across languages as a way to emphasize a non-empty result.
Definition and semantics: Given an element x of type A, listOf1(x) returns a List<A> containing x as
Language variants and examples: In Kotlin, a one-element list can be created with listOf(x). In Java, Collections.singletonList(x)
Relation to non-empty lists and data types: In functional programming, non-empty list types (often called NonEmpty
See also: singleton list, NonEmpty list, List1, listOf, Collections.singletonList.