I&#39;ll first try to give you a more understandable syntax. (I hope.)<div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div><font face="&#39;courier new&#39;, monospace">nubSym :: Ord a =&gt; [(a,a)] -&gt; [(a,a)]</font></div>
<div><font face="&#39;courier new&#39;, monospace">nubSym xs = nub (map fix xs)</font></div><div><font face="&#39;courier new&#39;, monospace">  where fix (a,b) | a &gt; b     = (b,a)</font></div><div><font face="&#39;courier new&#39;, monospace">                  | otherwise = (a,b)</font></div>
</span></div><div> <br>The two changes above are getting rid of the point-free style[1] and trading the pattern matching syntax for guards[2].</div><div>In the first version the <font class="Apple-style-span" face="&#39;courier new&#39;, monospace">p</font> was for matching with any parameter that didn&#39;t match the first definition. You may want to have a look at how pattern matching in Haskell works. (Well, you can find lots of resources about this one but I would have a look at [3])</div>
<div><br></div><div>[1] <a href="http://www.haskell.org/haskellwiki/Pointfree">http://www.haskell.org/haskellwiki/Pointfree</a></div><div>[2] <a href="http://en.wikibooks.org/wiki/Haskell/Control_structures#Guards">http://en.wikibooks.org/wiki/Haskell/Control_structures#Guards</a></div>
<div>[3] <a href="http://learnyouahaskell.com/syntax-in-functions">http://learnyouahaskell.com/syntax-in-functions</a></div><div><br></div><div>happy hacking! :)</div><div><br></div><div><div class="gmail_quote">On 28 September 2010 11:14, Martin Tomko <span dir="ltr">&lt;<a href="mailto:martin.tomko@geo.uzh.ch">martin.tomko@geo.uzh.ch</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


  

<div bgcolor="#ffffff" text="#000000">
Hi Ozgur,<br>
well, I am getting a list of tuples from a previous function, and they
relate to edges in graphs, so I am not too keen to change that,
although that could be possible. But I never worked with sets in
Haskell, so will have to study.<br>
<br>
Regarding your suggestion - I have to study it, it is a bit advanced.
First, I see there is no paramter to nubSym  - I have never used that
syntax, shouldn&#39;t there be something like nymSym (x:xs) or so? <br>
Second, obviously there is a local function, fix. I understand this: <font>fix (a,b) | a &gt; b = (b,a)</font><br>
<font>but I am not sure how to interpret this:</font><br>
<font>fix p = p. Where does p come from? How
does haskell know that it relates to (a,b), or the x as parameter?</font><br>
<br>
<font>Just asking for clarification ,as I am
new to all this.</font><br>
<br>
<font>Thanks </font><br><font color="#888888">
<font>M.</font></font><div><div></div><div class="h5"><br>
<br>
On 9/28/2010 12:05 PM, Ozgur Akgun wrote:
<blockquote type="cite">
  <div class="gmail_quote">Hi,</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">On 28 September 2010 10:33, Martin Tomko <span dir="ltr">&lt;<a href="mailto:martin.tomko@geo.uzh.ch" target="_blank">martin.tomko@geo.uzh.ch</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">I
have a list of (a,a) tuples, and am trying something like nub, but also
matching for symmetrical tuples.</blockquote>
  </div>
  <div><br>
  </div>
You can of course do this. One approach would be to simply &#39;fix&#39; the
tuples according to some ordering, and then use standard nub - or a
better one.
  <div><br>
  </div>
  <div>But to me, the real question is this: If the order of your
tuples to don&#39;t matter, do you actually need tuples? There are other
types in which the order of the elements in a container does not change
the meaning; such as a set. You may want to use a Set from Data.Set, or
you can define a pair type in which ordering doesn&#39;t matter. It will
end up being a cardinality restricted set type though.</div>
  <div><br>
  </div>
  <div>If you just want to get it working, here is some code for the
first option:</div>
  <div><br>
  </div>
  <div>
  <div><font face="&#39;courier new&#39;, monospace">nubSym
:: Ord a =&gt; [(a,a)] -&gt; [(a,a)]</font></div>
  <div><font face="&#39;courier new&#39;, monospace">nubSym
= nub . map fix</font></div>
  <div><font face="&#39;courier new&#39;, monospace">  where
fix (a,b) | a &gt; b = (b,a)</font></div>
  <div><font face="&#39;courier new&#39;, monospace">  
     fix p = p</font></div>
  <div><br>
  </div>
Cheers,
  </div>
  <div>Ozgur</div>
</blockquote>
<br>
<br>
</div></div></div>

</blockquote></div><br><br clear="all"><br>-- <br>Ozgur Akgun<br>
</div>