[Haskell-beginners] Unique integers in a list

KC kc1956 at gmail.com
Wed Mar 28 09:29:18 CEST 2012


Sort then ...


On Tue, Mar 27, 2012 at 7:03 PM, Ramesh Kumar <
rameshkumar.techdynamics at 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 at 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.htm>


More information about the Beginners mailing list