Parametric polymorphism: Difference between revisions

Content added Content deleted
Line 758: Line 758:
end
end


Tree(v::T) where {T} = Tree(v, nothing, nothing) # Single arg constructor
# Constructor with default values
function Tree(v::T) where T
Tree(v, nothing, nothing)
end


"""
"""
Apply `f` (element-wise and in-place) to the values in tree `bt`.
Applies `f` (element-wise and in-place) to the values in tree `bt`.
Also prints the tree in an s-expression form *for demonstrative purposes only*,
Prints the tree in an s-expression form *for demonstrative purposes only*,
new types should override the `show()` function for pretty-printing.
new types should override the `show()` function for pretty-printing.
"""
"""