Reputation: 13
Here is the layout of my problem:
ids :: [Integer] -- A list of Integers.
db :: [(Integer, Name)] -- A list of integer ids with the corresponding names
How do I retrieve every tuple from the db
where the id from the tuple matches at least one integer from my ids
list?
Thanks!
Upvotes: 1
Views: 103
Reputation: 7159
You may use filter
function:
query = filter (\t -> fst t `elem` ids) db
or more "elegant" pointfree version
query = filter ((`elem` ids) . fst) db
If you like list comprehensions use
[t | t <- db, fst t `elem` ids]
Upvotes: 4