>You forgot the parenthesis. Parse error in pattern usually means a type
in the input of one of your functions. Nub needs >elements that can be
equal.<br><br>type has to be typo. <br><div class="gmail_quote">On Tue, Sep 28, 2010 at 11:44 AM, edgar klerks <span dir="ltr"><<a href="mailto:edgar.klerks@gmail.com">edgar.klerks@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi Martin, <br><br>You have some typos:<br><br>import Data.List<br>removeDuplTuples :: (Eq a) => [(a,a)] -> [(a,a)]<div class="im">
<br>removeDuplTuples [] = []<br>removeDuplTuples [b] = [b] -- using the syntactic sugar for single element in list<br>
removeDuplTuples (x:xs) = nub (if elem (snd x,fst x) xs then removeDuplTuples xs else [x] ++ removeDuplTuples xs)<br></div> --------<br>You forgot the parenthesis. Parse error in pattern usually means a type in the input of one of your functions. Nub needs elements that can be equal.<br>
<br> Nub is quitte inefficient, if your elements can be ordered, there is a more efficient version. It is something like: <br><br>fmap head.group.sort $ [1,1,1,1,4,4,5,6,6,7,8,9]<br>
[1,4,5,6,7,8,9]<br>
<br>
But I haven't test it thoroughly. <br><br>Greets,<br><font color="#888888"><br>Edgar <br></font><div><div></div><div class="h5"><br><div class="gmail_quote">On Tue, Sep 28, 2010 at 11:33 AM, Martin Tomko <span dir="ltr"><<a href="mailto:martin.tomko@geo.uzh.ch" target="_blank">martin.tomko@geo.uzh.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi all,<br>
I apologize for spamming this forum so frequently, but there is noone I can turn to around here...<br>
I have a list of (a,a) tuples, and am trying something like nub, but also matching for symmetrical tuples. I implemented it using the template from delete from Prelude. Seems like my typse signature has some troubles (Paarse error in pattern) but I am not sure where the problem is.<br>
<br>
removeDuplTuples :: [(a,a)] -> [(a,a)]<br>
removeDuplTuples [] = []<br>
removeDuplTuples [b] = [b] -- using the syntactic sugar for single element in list<br>
removeDuplTuples x:xs = nub (if elem (snd x,fst x) xs then removeDuplTuples xs else [x] ++ removeDuplTuples xs)<br>
<br>
I assume the problem lies in elem (snd x,fst x) xs but I am not sure how to rewrite it.<br>
<br>
Thanks for all help,<br>
Martin<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br>
</div></div></blockquote></div><br>