Navigation
Synopsis Convert a list to a set.
Function set[&T] toSet(list[&T] lst)
Usage import List;
Description Convert lst to a set.
Examples
rascal>import List;
ok
rascal>toSet([10, 20, 30, 40]);
set[int]: {40,10,20,30}
rascal>toSet(["zebra", "elephant", "snake", "owl"]);
set[str]: {"snake","owl","zebra","elephant"}
Note that the same can be done using splicing
rascal>l = [10,20,30,40];
list[int]: [10,20,30,40]
rascal>s = {*l};
set[int]: {40,10,20,30}

Questions
Question [1].
The type of toSet([-18, 17, 19]) is

Question [2].
toSet(["Saffron"]) == 



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.