The module allows you to generate your own binary trees and display them beautifully.
This package available in Hex and can be installed
by adding bintree
to your list of dependencies in mix.exs
:
def deps do
[
{:bintree, "~> 1.1.0"}
]
end
Bintree.new(2, &(&1*2), &(&1 * 3), 4)
|> IO.puts()
# Result:
# 2
# |
# /---------------\
# | |
# 4 6
# | |
# /-------\ /-------\
# | | | |
# 8 12 12 18
# | | | |
# /---\ /---\ /---\ /---\
# | | | | | | | |
#16 24 24 36 24 36 36 54