[Haskell-beginners] repetition

Henk-Jan van Tuyl hjgtuyl at chello.nl
Thu Aug 4 11:53:09 CEST 2011


On Thu, 04 Aug 2011 11:31:02 +0200, Luca Ciciriello  
<luca_ciciriello at hotmail.com> wrote:

> Hi All.
> Is there any function in Prelude that removes the repeated elements in a  
> list?
>
> In example I've a list like this one: xs =  
> ["3","3","3","3","3","4","4","4","4","4","5","5","5","5","5","6","6","6","6","6","6","6"]
>
> I need a function f such that f xs = ["3","4","5","6"]
>

Not in Prelude, but in Data.List:
   nub

Prelude Data.List> nub  
["3","3","3","3","3","4","4","4","4","4","5","5","5","5","5","6","6","6","6","6","6","6"]
["3","4","5","6"]

Regards,
Henk-Jan van Tuyl


-- 
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--



More information about the Beginners mailing list