What list name has only one item

What is a โ€œformalโ€ list name in which there is only one item?

+4
source share
3 answers

Java Collections calls this singleton list, although I don't think it is a formal name.

public static List singletonList (T o) Returns an immutable list containing only the specified object. The returned list is serializable.

I prefer the "list of single elements".

Change Singleton seems to be a valid math term for a single set of elements.

+7
source

I would call it unitList (to avoid confusion with the Singleton pattern ) in a math collection containing only one element is also known as a collection

+4
source

You can call it singleton, as this is the correct mathematical term for a one-element set. However, the term singleton is used differently in computer science and usually refers to an object from which there is exactly one instance at any given time during program execution, so it can be misleading or confusing, so I would avoid using it for one set of elements.

In mathematics, a set with exactly one element is also known as a unit set. This is the name I would go for.

0
source

All Articles