Navigation
Synopsis Convert a set of tuples to a map (provided that there are no multiple keys).
Function map[&A,&B] toMapUnique(rel[&A, &B] st) throws MultipleKey
Usage import Set;
Description Convert a set of tuples to a map. The result should be a legal map (i.e., without multiple keys).
Examples
rascal>import Set;
ok
rascal>toMapUnique({<"a", 1>, <"b", 2>, <"c", 10>});
map[str, int]: ("a":1,"b":2,"c":10)
Now explore an erroneous example:
rascal>toMapUnique({<"a", 1>, <"b", 2>, <"a", 10>});
|rascal://Set|(11348,931,<562,0>,<601,70>): MultipleKey("a")
	at *** somewhere ***(|rascal://Set|(11348,931,<562,0>,<601,70>))
	at toMapUnique(|stdin:///|(39,2,<1,39>,<1,41>))



Questions
Question [1].
The type of toMapUnique({<7,6>,<-16,-12>,<-13,-11>,<-9,-13>,<10,14>,<15,-10>}) is

Question [2].
toMapUnique({<9,-11>,<5,-20>,<-17,-10>,<-16,2>,<10,-19>,<-5,-4>}) == 



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.