This code does Huffman coding, using the queue implementation. This can be used for constructing Huffman encodings, or for computing factorials efficiently.
- huffmanFold :: Ord a => (a -> a -> a) -> [a] -> a
Documentation
huffmanFold :: Ord a => (a -> a -> a) -> [a] -> aSource
huffmanFold op l where op is associative, l is a nonempty monotonically increasing list, and op has the property that (x1>=x2,y1>=y2) => (op x1 y1>=op x2 y2) computes the fold of l with op, by repeatedly folding the smallest two elements of the list until only one remains.