Hi Tomasz,<br><br>I actually quite like this style.&nbsp; I was able to understand it after spending some time reading the docs for some of the functions you used.<br><br>My problem I guess is being able to write the code this way when the need arises or even just recognising when and where it&#39;s an option, both of which to me is considerably harder.
<br><br>Thanks for the tip.<br><br>-John<br><br>On 1/29/07, <b class="gmail_sendername">Tomasz Zielonka</b> &lt;<a href="mailto:tomasz.zielonka@gmail.com">tomasz.zielonka@gmail.com</a>&gt; wrote:<div><span class="gmail_quote">
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Mon, Jan 29, 2007 at 10:10:47PM +1100, John Ky wrote:<br>&gt; I&#39;ve written some code and was wondering if there was a better way to write
<br>&gt; it in terms of readability, brevity and/or efficiency.<br><br>This version of mergeForest2 should be more efficient. For even better<br>efficiency it should use Data.Sequence for efficient concatenation<br>(instead of ++). I also made it more general. You have to judge
<br>readability yourself.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;import qualified Data.Map as Map<br><br>&nbsp;&nbsp;&nbsp;&nbsp;data ArcData = ArcData<br>&nbsp;&nbsp;&nbsp;&nbsp; { name :: String<br>&nbsp;&nbsp;&nbsp;&nbsp; } deriving (Show, Eq, Ord) -- derive Ord and Eq<br><br>&nbsp;&nbsp;&nbsp;&nbsp;mergeForest2 :: (Ord k) =&gt; [Tree k] -&gt; Forest k
<br>&nbsp;&nbsp;&nbsp;&nbsp;mergeForest2 =<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;map pairToNode .<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Map.toList .<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Map.map mergeForest2 .<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Map.fromListWith (++) .<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;map nodeToPair<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nodeToPair (Node x y) = (x, y)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pairToNode = uncurry Node<br><br>Best regards<br>Tomasz<br></blockquote></div><br>