Hi,<br><br>Sorry for there is a bug in my previous post.<br><br>The example consolidate function for number should be like this:<br><br>consolidate xs = foldl meld [] xs where<br>&nbsp;&nbsp;&nbsp; meld [] x = [x]<br>&nbsp;&nbsp;&nbsp; meld (x':xs) x | x == x' = meld xs (x+x')<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | x &lt; x'&nbsp; = x:x':xs<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | otherwise = x': meld xs x<br><br>The bug happens in my previous mail like below.<br><br>--------before fixing--------<br>&gt;consolidate [2, 1, 1, 32, 4, 8, 1, 1, 2, 4]<br>&gt;[16,4,32,4]<br><br>--------after fixing----------<br>&gt;consolidate [2, 1, 1, 32, 4, 8, 1, 1, 2, 4]<br>
&gt;[8, 16, 32]<br><br>Therefore, the consolidate function for unordered binomial trees should be modified as the following respectively.<br><br>consolidate :: (Ord a) =&gt; [BiTree a] -&gt; [BiTree a]<br>consolidate ts = foldl meld [] ts where<br>&nbsp;&nbsp;&nbsp; meld [] t = [t]<br>&nbsp;&nbsp;&nbsp; meld (t':ts) t | rank t == rank t' = meld ts (link t t')<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | rank t &lt;&nbsp; rank t' = t:t':ts<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | otherwise = t' : meld ts t<br><br>I am sorry for this mistake.<br><br>The updated source code can be found from here:<br>https://sites.google.com/site/algoxy/otherheaps/otherheaps.zip<br><br>Happy new year.<br><br>--<br>Larry, LIU<br><br>