Possible Duplicate:
Return a list of Integer values that is not within a range of numbers in an existing list:
I’m looking to take the following:
[Vacant, Engaged, Vacant, Vacant, Engaged, Vacant, Vacant, Vacant, Vacant]
and return a list of only Vacant values from the above list.
(i.e. [Vacant, Vacant, Vacant, Vacant, Vacant, Vacant, Vacant]).
Is there any predefined haskell function to perform this operation?
(n.b. Vacant and Engaged are data types)
It’s called
filter:Alternatively, use a list comprehension:
(Slightly longer in this case, but more convenient in some other circumstances.)