Map collections without turning them into lists

Viewed 144

Is it possible to map collections without turning them into lists? I know about mapv for vectors, but what about sets or maps. Is there a generic map function that treats each collection as a functor (i.e. something mappable) and preserves its type after mapping?

Here is what i have mind vs whats happening now:

(map inc [1 2 3])         ; => [2 3 4], instead I get: (2 3 4)
(map inc #{1 2 3})        ; => #{3 2 4}, instead I get: (3 2 4)
(map inc {:a 1 :b 2 :c 3} ; => {:a 2 :b 3 :c 4}, instead I get: ClassCastException
2 Answers
Related