Huffman

Source

Summary

decode(encoded, keys)

Taking a set of keys and an encoded binary, turns it back into text. Example

do_decode(encoded, keys)
do_decode(encoded, tree, decoded)
encode(bin)

Encodes the supplied binary, returning the encoded binary and the binary code => key mappings

Functions

decode(encoded, keys)

Taking a set of keys and an encoded binary, turns it back into text. Example

iex> {encoded, keys} = Huffman.encode "Lil Wayne is the best rapper alive."
iex> Huffman.decode encoded, keys
"Lil Wayne is the best rapper alive."
Source
do_decode(encoded, keys)
Source
do_decode(encoded, tree, decoded)
Source
encode(bin)

Encodes the supplied binary, returning the encoded binary and the binary code => key mappings.

Example: iex> {encoded, keys} = Huffman.encode “Lil Wayne is the best rapper alive.” iex> encoded <<120, 78, 203, 140, 247, 7, 234, 91, 183, 29, 114, 181, 92, 94, 208, 67, 14::size(6)>> iex> keys %{<<0::size(3)>> => “i”, <<2::size(4)>> => “r”, <<3::size(4)>> => “s”, <<4::size(4)>> => “l”, <<5::size(4)>> => “p”, <<12::size(5)>> => “W”, <<13::size(5)>> => “b”, <<14::size(5)>> => “.”, <<15::size(5)>> => “L”, <<16::size(5)>> => “v”, <<17::size(5)>> => “y”, <<18::size(5)>> => “h”, <<19::size(5)>> => “n”, <<10::size(4)>> => “t”, <<11::size(4)>> => “a”, <<6::size(3)>> => “e”, <<7::size(3)>> => “ “}

Source