vertmanip
vertmanip

Reputation: 25

How can I apply a predicate to a set?

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?

Upvotes: 1

Views: 75

Answers (1)

Óscar López
Óscar López

Reputation: 236004

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}

Upvotes: 1

Related Questions