Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  repetition (Thomas Davie)
   2. Re:  repetition (Luca Ciciriello)
   3. Re:  repetition (Luca Ciciriello)
   4. Re:  repetition (Henk-Jan van Tuyl)


----------------------------------------------------------------------

Message: 1
Date: Thu, 4 Aug 2011 10:39:18 +0100
From: Thomas Davie <[email protected]>
Subject: Re: [Haskell-beginners] repetition
To: Lyndon Maydwell <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii


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



------------------------------

Message: 2
Date: Thu, 4 Aug 2011 11:41:34 +0200
From: Luca Ciciriello <[email protected]>
Subject: Re: [Haskell-beginners] repetition
To: Thomas Davie <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

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




------------------------------

Message: 3
Date: Thu, 4 Aug 2011 11:44:31 +0200
From: Luca Ciciriello <[email protected]>
Subject: Re: [Haskell-beginners] repetition
To: Thomas Davie <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

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
> 




------------------------------

Message: 4
Date: Thu, 04 Aug 2011 11:53:09 +0200
From: "Henk-Jan van Tuyl" <[email protected]>
Subject: Re: [Haskell-beginners] repetition
To: [email protected], "Luca Ciciriello"
        <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
        delsp=yes

On Thu, 04 Aug 2011 11:31:02 +0200, Luca Ciciriello  
<[email protected]> 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
--



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 38, Issue 7
****************************************

Reply via email to