Sets can also be denoted by a set compehension expression. Examples are:
{X**2::X in L & not X in [0,1]} % Squares of numbers other than 0,1 in L, duplicates removed. {A :: exists C, P (child_of(C,P) & age_of(C,A) & A<18)} % Set of all the ages of recorded children
The general form of a set comprehension is:
{Expression :: exists VarSequence Condition}
where the exists VarSequence
is optional.
The constraints on the variables that can be used in a set comprehension are the same as those for a list comprehnesion expression.
VarSequence
and Condition
are as for list comprehensions.