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