![]() |
|
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].
![]() ![]()
Question [2].
![]() ![]() ![]() |