The textbook Language Proof and Logic provides these English expressions for the universal and existential quantifiers that Professor Odersky referred to.
The universal quantifier ∀
is used to express universal claims, those we express in English using
quantifed phrases like everything, each thing, all things, and anything.
The existential quantifier ∃
is used to express existential claims, those we express in English using such phrases as something, at least one thing, a, and an.
The mention of these terms was probably related or lead into operations on collections using higher order functions. In Scala, the transition from logic to code is quite natural with the forall
and exists
operations on a collection. These are analogous to the universal and existential definitions given above. Some simple examples are helpful to show this:
scala> val l = 1 to 10
l: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
scala> l.forall(x => x > 0)
res0: Boolean = true
scala> l.forall(x => x > 1)
res1: Boolean = false
These two forall
statements are simply asking do all elements of this collection meet the criteria.
scala> l.exists(x => x < 1)
res2: Boolean = false
scala> l.exists(x => x < 2)
res3: Boolean = true
These two exists
statements are simply asking do any elements of this collection meet the criteria.