Add something here ...
~kc4zvw:
Add something here ...
Add something here ...
Add something here ...
Add something here ...
import Data.Graph.Inductive.Internal.Heap( Heap(..),insert,findMin,deleteMin) -- heapsort is added in this module as an example application build :: Ord a => [(a,b)] -> Heap a b build = foldr insert Empty toList :: Ord a => Heap a b -> [(a,b)] toList Empty = [] toList h = x:toList r where (x,r) = (findMin h,deleteMin h) heapSort :: Ord a => [a] -> [a] heapSort = (map fst) . toList . build . map (\x->(x,x))
kc4zvw@www:~$ ghci GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help Prelude> :load heapsort.hs [1 of 1] Compiling Main ( heapsort.hs, interpreted ) Ok, one module loaded. *Main> heapSort [9,5,8,2,1,4,6,3,0,7] [0,1,2,3,4,5,6,7,8,9] *Main> :quit Leaving GHCi. kc4zvw@www:~$
Add something here ...