# repetition

11 messages
Open this post in threaded view
|

## repetition

 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"] thanks in advance for any answer. Luca
Open this post in threaded view
|

## repetition

 On 4 Aug 2011, at 10:31, Luca Ciciriello 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"] > > thanks in advance for any answer. map head . group Bob
Open this post in threaded view
|

## repetition

 In reply to this post by Luca Ciciriello Hi. On 4 August 2011 10:31, Luca Ciciriello wrote: > Is there any function in Prelude that removes the repeated elements in a > list? > http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v:nubHTH, Ozgur -------------- next part -------------- An HTML attachment was scrubbed... URL:
Open this post in threaded view
|

## repetition

 In reply to this post by Thomas Davie nub > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners>
Open this post in threaded view
|

## repetition

 Ah sorry, nub that requires importing Data.List. My mistake! On Thu, Aug 4, 2011 at 5:36 PM, Lyndon Maydwell wrote: > nub > >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners>> >
Open this post in threaded view
|

## repetition

 In reply to this post by Lyndon Maydwell On 4 Aug 2011, at 10:36, Lyndon Maydwell wrote: > nub Heh, our differing answers point out an ambiguity in the question. Luca, given [5,10,10,5] what is this function expected to produce? if you want [5,10] then nub is correct. if you want [5,10,5] then map head . group is correct. Bob
Open this post in threaded view
|

## repetition

 In reply to this post by Thomas Davie Thanks. Luca. On Aug 4, 2011, at 11:33 AM, Thomas Davie wrote: > > On 4 Aug 2011, at 10:31, Luca Ciciriello 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"] >> >> thanks in advance for any answer. > > map head . group > > Bob
Open this post in threaded view
|

## repetition

 In reply to this post by Thomas Davie My mistake, I haven't specified that the starting list is ordered. Luca On Aug 4, 2011, at 11:39 AM, Thomas Davie wrote: > > On 4 Aug 2011, at 10:36, Lyndon Maydwell wrote: > >> nub > > Heh, our differing answers point out an ambiguity in the question. > > Luca, given [5,10,10,5] what is this function expected to produce? > > if you want [5,10] then nub is correct. > if you want [5,10,5] then map head . group is correct. > > Bob >
Open this post in threaded view
|

## repetition

 In reply to this post by Luca Ciciriello On Thu, 04 Aug 2011 11:31:02 +0200, Luca Ciciriello   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--