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