What’s a set comprehension?

  • An expression that evaluates to a set
  • A feature of some programming languages (e.g., Python) What does a set comprehension look like?
  • all x such that p(x) is true
  • all natural numbers that satisfy p(x)
  • all even numbers up to 100
  • Python version

How does a compiler process a set comprehension?

  • Generate a loop over the domain of objects