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