Navigation
Synopsis Convert a set of tuples to a map; each key is associated with a set of values.
Function map[&A,set[&B]] toMap(rel[&A, &B] st)
Usage import Set;
Description Convert a set of tuples to a map in which the first element of each tuple is associated with the set of second elements of all tuples with the same first element.
Examples
rascal>import Set;
ok
rascal>toMap({<"a", 1>, <"b", 2>, <"a", 10>});
map[str, set[int]]: (
  "a":{1,10},
  "b":{2}
)

Questions
Question [1].
The type of toMap({<13, -15>, <-12, 0>, <15, -20>, <-3, 4>, <11, 2>, <-13, -2>}) is

Question [2].
toMap({<10, -4>, <11, 14>, <9, -9>, <3, 11>, <-11, 6>, <-12, 2>, <-18, 19>}) == 



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.