tags:

views:

34

answers:

1

There are some collections - let's say each collection is set of programming languages a developer knows.

{"Alice" => Set["Java", "Python", "C++"], "Bob" => Set["Ruby"], "Charlie" => Set["Ruby", "C++"]}.

I want to group these objects by collections they belong to - in this case getting a mapping from sets of developers sharing knowledge of certain languages to sets of such languages. Every language present in the input will occur exactly once here:

{Set["Alice"] => Set["Java", "Python"], Set["Alice", "Charlie"] => Set["C++"], Set["Bob", "Charlie"] => Set["Ruby"]}

Type of this operation would be Hash[A, Set[B]] => Hash[Set[A], Set[B]]. (in practice plain arrays would most likely be used instead of sets, I'm using sets here to say that order doesn't matter and there are no duplicates)

I'm not asking how to code this operation (of course if you know a particularly elegant way, feel free to share) - I'm wondering if it has a name. It seems common enough that it should, but I cannot think of anything.

A: 

"Reverse Mapping"?

jsbueno
"reverse mapping" suggests something more like `Hash[A,B] => Hash[B,A]`, and is actually used this way in context of DNS - normally DNS system is like `Hash[Hostname,IP]`, but "reverse mapping" function makes it act like `Hash[IP,Hostname]` (simplifying things).
taw