Since the root comment talked about Python's set, you might want to have a look at Haskell's Data.Set. Haskell's Data.Map is more or less equivalent to Python's dict. You can also map and fold over Sets and Maps. There is no built-in function for applying a function to a set to get a map, but you can easily add one.