Regarding finding the number of unique elements in a list.
18 Jan 2002 10:31:17 +1100
I consider myself a newbie too but here are my solutions
On Fri, 2002-01-18 at 10:14, Amrit K Patil ;012;VKSF6; wrote:
> I am newbie at Haskell.
> I am not able to write a program to find the number of unique elments in a
> list in haskell.
> I am also not able to write a porgram to find the elements in the
> innermost list in a list within lists.
> Can anybody guide me as to g\how to go about it or better still send me
> the program.
> It would be of great help.
> Have a good day..
> Haskell-Cafe mailing list
Content-Disposition: attachment; filename=unique.hs
Content-Type: text/plain; charset=ISO-8859-1
--Function that returns true if
--an element in contained in the list
contains :: Eq a =3D> a -> [a] -> Bool
contains _  =3D False
contains a (x:xs) | a=3D=3Dx =3D True
| otherwise =3D contains a xs
--Function to remove all multiple
--occurences of elements in a list
unique :: Eq a =3D> [a] -> [a]
unique  =3D 
unique (x:xs) | contains x xs =3D unique xs
| otherwise =3D x:unique xs
innerList :: [[a]] -> [a]
innerList =3D foldr (++)