Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

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


Today's Topics:

   1. Re:  Unique integers in a list (KC)
   2. Re:  Beginners Digest, Vol 45, Issue 35 (franc...@gmx.com)
   3. Re:  Beginners Digest, Vol 45, Issue 35 (franc...@gmx.com)
   4. Re:  Beginners Digest, Vol 45, Issue 35 (Ramesh Kumar)
   5. Re:  Beginners Digest, Vol 45, Issue 35 (franc...@gmx.com)


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

Message: 1
Date: Wed, 28 Mar 2012 00:29:18 -0700
From: KC <kc1...@gmail.com>
Subject: Re: [Haskell-beginners] Unique integers in a list
To: Ramesh Kumar <rameshkumar.techdynam...@ymail.com>,
        Beginners@haskell.org
Message-ID:
        <CAMLKXykNY81n9+_ZRHa2Ox=nvnz7erhw9hfff4r5vaa5aso...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Sort then ...


On Tue, Mar 27, 2012 at 7:03 PM, Ramesh Kumar <
rameshkumar.techdynam...@ymail.com> wrote:

> Hi,
>
> I've just started learning Haskell a couple of weeks ago using Simon
> Thompson's "Haskell: Craft of Functional Programming".
> There is an exercise in chapter 7 of the book which goes something like
> this:
>
> Define a function of the type:     unique :: [Integer] -> [Integer]
> which if given a list of integers, should return a list of those integers
> which occur only once in the input list.
> Example:
>    unique [5,2,4,2,3,1,5,2] should result in [4,3,1]
>
>
> *** The questions assumes we know only of list comprehensions and
> recursion.
>
> I am guessing the solution must include something like this:
>
> unique :: [Integer] -> [Integer]
> unique xs = [ x | x <- xs, isSingle x ]
>
> My problem is in defining the function 'isSingle'.
>
> I would greatly appreciate any pointers on this.
>
> Many thanks.
> Ramesh
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>


-- 
--
Regards,
KC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120328/c78d488e/attachment-0001.htm>

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

Message: 2
Date: Wed, 28 Mar 2012 09:36:33 +0200
From: franc...@gmx.com
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 45, Issue 35
To: beginners@haskell.org
Message-ID: <20120328073633.134...@gmx.com>
Content-Type: text/plain; charset="utf-8"

unique :: [Integer] -> [Integer]
 unique [] = []
 unique (x:xs) | elem x xs = (unique . filter (/= x)) xs
 | otherwise = x : unique xs

 -- This is a simpler to read version (albeit inefficient?)
 unique :: [Integer] -> [Integer]
 unique [] = []
 unique (x:xs) | elem x xs = unique xs
 | otherwise = x : unique xs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120328/2ada60ea/attachment-0001.htm>

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

Message: 3
Date: Wed, 28 Mar 2012 09:39:15 +0200
From: franc...@gmx.com
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 45, Issue 35
To: beginners@haskell.org
Message-ID: <20120328073916.134...@gmx.com>
Content-Type: text/plain; charset="utf-8"

gah sorry I obviously meant to reply to the "Unique integers in a list" message



----- Original Message -----
From: franc...@gmx.com
Sent: 03/28/12 09:36 AM
To: beginners@haskell.org
Subject: Re: Beginners Digest, Vol 45, Issue 35

unique :: [Integer] -> [Integer]
 unique [] = []
 unique (x:xs) | elem x xs = (unique . filter (/= x)) xs
 | otherwise = x : unique xs

 -- This is a simpler to read version (albeit inefficient?)
 unique :: [Integer] -> [Integer]
 unique [] = []
 unique (x:xs) | elem x xs = unique xs
 | otherwise = x : unique xs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120328/377a7882/attachment-0001.htm>

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

Message: 4
Date: Wed, 28 Mar 2012 01:14:24 -0700 (PDT)
From: Ramesh Kumar <rameshkumar.techdynam...@ymail.com>
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 45, Issue 35
To: "franc...@gmx.com" <franc...@gmx.com>,      "beginners@haskell.org"
        <beginners@haskell.org>
Message-ID:
        <1332922464.98641.yahoomail...@web120201.mail.ne1.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"

Thanks Franco, Your (first) solution is the only one which has worked so far 
although it utilizes a lambda expression.
The problem is indeed tricky. 






>________________________________
> From: "franc...@gmx.com" <franc...@gmx.com>
>To: beginners@haskell.org 
>Sent: Wednesday, March 28, 2012 3:39 PM
>Subject: Re: [Haskell-beginners] Beginners Digest, Vol 45, Issue 35
> 
>
>gah sorry I obviously meant to reply to the "Unique integers in a list" message
>
>
>
>
>?
>----- Original Message -----
>>From: franc...@gmx.com
>>Sent: 03/28/12 09:36 AM
>>To: beginners@haskell.org
>>Subject: Re: Beginners Digest, Vol 45, Issue 35
>>
>>unique :: [Integer] -> [Integer]
>>unique []?? = []
>>unique (x:xs) | elem x xs?? = (unique . filter (/= x)) xs
>>????????????? | otherwise?? = x : unique xs
>>
>>-- This is a simpler to read version (albeit inefficient?)
>>unique :: [Integer] -> [Integer]
>>unique []?? = []
>>unique (x:xs) | elem x xs?? = unique xs
>>????????????? | otherwise?? = x : unique xs
>? 
>_______________________________________________
>Beginners mailing list
>Beginners@haskell.org
>http://www.haskell.org/mailman/listinfo/beginners
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120328/a9dded99/attachment-0001.htm>

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

Message: 5
Date: Wed, 28 Mar 2012 10:38:26 +0200
From: franc...@gmx.com
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 45, Issue 35
To: "Ramesh Kumar"
        <rameshkumar.techdynam...@ymail.com>,beginners@haskell.org
Message-ID: <20120328083826.134...@gmx.com>
Content-Type: text/plain; charset="utf-8"

Indeed the second snipper contains quite an obvious mistake. Thanks for 
noticing!

 It doesn't seem to me it utilises a lambda expression though? You mean the '.' 
operator for chaining function? If that's it, it could be rewritten

 unique :: [Integer] -> [Integer]
 unique [] = []
 unique (x:xs) | elem x xs = unique (filter (/= x) xs)
 | otherwise = x : unique xs





----- Original Message -----
From: Ramesh Kumar
Sent: 03/28/12 10:14 AM
To: franc...@gmx.com, beginners@haskell.org
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 45, Issue 35

Thanks Franco, Your (first) solution is the only one which has worked so far 
although it utilizes a lambda expression.
The problem is indeed tricky. 

-----------------------------------------------------------------
From: "franc...@gmx.com" <franc...@gmx.com>
To: beginners@haskell.org
Sent: Wednesday, March 28, 2012 3:39 PM
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 45, Issue 35

gah sorry I obviously meant to reply to the "Unique integers in a list" message



----- Original Message -----
From: franc...@gmx.com
Sent: 03/28/12 09:36 AM
To: beginners@haskell.org
Subject: Re: Beginners Digest, Vol 45, Issue 35

unique :: [Integer] -> [Integer]
 unique [] = []
 unique (x:xs) | elem x xs = (unique . filter (/= x)) xs
 | otherwise = x : unique xs

 -- This is a simpler to read version (albeit inefficient?)
 unique :: [Integer] -> [Integer]
 unique [] = []
 unique (x:xs) | elem x xs = unique xs
 | otherwise = x : unique xs
 _______________________________________________
 Beginners mailing list
 Beginners@haskell.org 
http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120328/598cb767/attachment.htm>

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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 45, Issue 36
*****************************************

Reply via email to