• Returns a string describing the tree, on a single line. This function is curried, takes a printing function for the values as first parameter, and then returns a function taking the root of a tree to display.

    Parameters

    • dispFun: ((a: any) => string) = ...

      a function that displays a single element

        • (a): string
        • Parameters

          • a: any

          Returns string

    • nodeName: string = "node"

      a string for displaying nodes

    • leafName: string = "leaf"

      a string for displaying leaves

    Returns ((a: TreeI<any>) => string)

    a function displaying a tree

      • (a): string
      • Parameters

        Returns string

    treeToString()(node(1, [leaf(2), leaf(3)])); // -> "node(1, [leaf(2),leaf(3)])"
    treeToString((x) => ".".repeat(x))
    (node(1, [leaf(2), leaf(3)])); // -> node(., [leaf(..),leaf(...)])