showell / binary-tree-diagram / BinaryTreeDiagram

Create a diagram of a binary tree.


type BinaryTree v
    = Node v (BinaryTree v) (BinaryTree v)
    | Empty

Example tree:

Node 2 (Node 1 Empty Empty) (Node 3 Empty Empty)

The arguments are value, leftTree, rightTree.

diagramView : (v -> String) -> (v -> String) -> BinaryTree v -> Html msg

Pass in functions to set the color and text.

diagramView (\v -> v.color) (\v -> v.text) tree

diagramView (\_ -> "blue") (\_ -> "") tree