Python programming language, among others, has a construct to create lists which is called a list comprehension.
A simple example:
[(2*n) for n in range(1, 6)]
generates a list of numbers: [2, 4, 6, 8, 10]. For integers between 1 and 5, it multiplies each n by 2 and returns a new list. This can be done for different data structures such as dictionaries and sets.
Wikipedia draws an analogy between set-builder notation and comprehensions: {2n | 1 ≦ n ≦ 5} can be seen as an equivalent of the above list comprehension for integer n. It also implies this notation is also known as "set comprehension".
The main definition of the word ("the ability to understand something") surely doesn't apply here. The Oxford English Dictionary lists a second meaning:
- archaic Inclusion.
The answerer here also suggests that it means inclusion in this context:
The name comes from the concept of a set-comprehension
Comprehension is used here to mean complete inclusion or complete description. A set-comprehension is a (usually short) complete description of a set, not an exhaustive (and possibly infinite) enumeration.
I can understand "complete description" but I am having a hard time associating the word "inclusion" with this concept, especially since "inclusion" has a specific meaning in set theory.
Does it really relate to inclusion or does it have a completely separate meaning?
{ 2n | 1 ≦ n ≦ 5}does not correspond to the set theory Axiom Schema of Comprehension (aka. Separation), but rather to the Axiom Schema of Replacement. That would rather be something like{ x in Z | exists n such that x = 2n & 1 ≦ n ≦ 5}. – Hagen von Eitzen Aug 21 '17 at 10:59x->2*x) should be applied to the entire list, and in compact, easily readable notation too! Compare also the answer of @Mitch below. – Axel Aug 21 '17 at 13:27