scala - List of first occurrences in original order -
suppose have x: list[a]
. elegant way of building y: list[a]
such y
contains first occurrence of each element of x
, in same order? interested in case a=int
if there general solution, better.
as correctly suggested twillouer, use .distinct
method. guarantees preserve order expect.
Comments
Post a Comment