Navigation
Synopsis Convert a set to a list.
Function list[&T] toList(set[&T] st)
Usage import Set;
Examples
rascal>import Set;
ok
rascal>toList({1, 2, 3, 4});
list[int]: [4,3,2,1]
rascal>toList({"elephant", "zebra", "snake"});
list[str]: ["elephant","zebra","snake"]
Note that the same result can be obtained using splicing:
rascal>s = {1,2,3,4};
set[int]: {1,2,3,4}
rascal>l = [*s];
list[int]: [1,2,3,4]
Pitfalls Recall that the elements of a set are unordered and that there is no guarantee in which order the set elements will be placed in the resulting list.

Questions
Question [1].
The type of toList({"J", "Wasabi", "Obi-Wan Kenobi", "Blackcurrant", "Blackberry"}) is

Question [2].
toList() == ["Date","M"]



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.