Hi Tomasz,<br><br>I actually quite like this style. 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'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> <<a href="mailto:tomasz.zielonka@gmail.com">tomasz.zielonka@gmail.com</a>> 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>> I've written some code and was wondering if there was a better way to write
<br>> 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> import qualified Data.Map as Map<br><br> data ArcData = ArcData<br> { name :: String<br> } deriving (Show, Eq, Ord) -- derive Ord and Eq<br><br> mergeForest2 :: (Ord k) => [Tree k] -> Forest k
<br> mergeForest2 =<br> map pairToNode .<br> Map.toList .<br> Map.map mergeForest2 .<br> Map.fromListWith (++) .<br> map nodeToPair<br> where<br> nodeToPair (Node x y) = (x, y)
<br> pairToNode = uncurry Node<br><br>Best regards<br>Tomasz<br></blockquote></div><br>