There is as far as I know, no widely accepted term in SW engineering to described a list with exactly one element
In mathematics, and more precisely in the set theory, a set with only one element is called a singleton. Unfortunately, in SW engineering, the term is so heavily associated with a design pattern, that using it for another purpose might create a confusion.
Anyway, a list is ordered, so a set is not a list. An ordered list of items is called a sequence in mathematics. And a sequence with exactly one element is called a 1-tuple. Unfortunately, a tuple corresponds to specific data structures, so this term, even converted to letters-only, would also be very ambiguous.
Finally, if mathematics don’t help, let’s look at literature! The contrary of plural is singular. According to the Meriam-Webster dictionary, it means “of, or relating to, one person, thing or instance”. So a singular list should express exactly what you want. This term is even reinforced by its ambiguity: “singular” is associated in other contexts with strangeness, and a list with only one element is indeed a strange list (as πάντα ῥεῖ already pointed out in the comments. But I’d nevertheless prefer to explain it a comment at first use ;-)
len(x)*len(y)==1
:) – 12Me21 Aug 26 '20 at 10:16len
of0
, but an uninitialized list had alen
of-1
, and-1 * -1 = 1
, but do you know, I cannot find any evidence at all to support that. I am truly getting old and senile. – Spratty Aug 26 '20 at 11:59HasSingleItem
,ContainsSingleItem
,NotPluralOrEmpty
. Inspired by linq and string methods names in C#. – Sinatr Aug 26 '20 at 14:23is_length_1
,is_count_1
,has_one_element
,are_one_item_lists
, etc. What you may want to review is if it's better for you to use singular or plural verbs, maybe plural fits better. – Andrew Sep 25 '20 at 05:45