How can I apply a predicate to a set?

79 Views Asked by At

Say I have a set, S = { 1, 2, 3, 4 } (the contents don't really matter)

I can say forall x in set S & x mod 2 = 0 but that will give me a boolean answer - are all the numbers in it even? What if I want to see all members of the set for which x mod 2 = 0 is true?

What's the syntax for applying a predicate to it? How can I filter for odd numbers, even numbers, numbers above/below 3.5 etc?

1

There are 1 best solutions below

1
On BEST ANSWER

Try this syntax, it'll return the members of the set for which the predicate is true:

{x | x in set S & x mod 2 = 0}