Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Prints a binary tree sideways *)
- type 'a tree =
- | Node of 'a tree * 'a * 'a tree
- | Nil
- let rec print t =
- let rec loop n = function
- | Nil -> ()
- | Node(l, x, r) ->
- let spaces = new System.String(' ', n * 4)
- loop (n + 1) r
- printfn "%s%A" spaces x
- loop (n + 1) l
- loop 0 t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement