[erlang-questions] Sets from list then to list?

Alexander Lamb alexander.lamb@REDACTED
Mon Apr 7 10:19:47 CEST 2008


Hello (list:-)

Using list comprehension, I am building a list of tuples that I want  
unique and sorted.

Is this a correct way of doing it:

Result = sets:to_list(sets:from_list([ {A,B} || {_X,_Y,A,_Z,B} <-  
MyList]))

Then sort the Result.

The alternative would be to use one of the lists functions to copy  
elements into a new list and testing first at each insert if the  
element is already present.

What is best?

Thanks,

Alex
--
Alexander Lamb
Founding Associate
RODANOTECH Sàrl

4 ch. de la Tour de Champel
1206 Geneva
Switzerland

Tel:  022 347 77 37
Fax: 022 347 77 38

http://www.rodanotech.ch






More information about the erlang-questions mailing list