Splitting Rose Trees
type 'a rtree = Node of 'a * 'a rtree list
Implement the function
val split : ('a * 'b) rtree -> 'a rtree * 'b rtree
so that split t constructs two trees of the same structure as
t, one with the left element of the tuple in each node of t, and
one with the right element of the tuple in each node.
Examples
let t = Node ((1, "a"), [Node ((2, "b"), []); Node ((3, "c"), [])])
let _ = assert (split t =
( Node (1, [Node (2, []); Node (3, [])])
, Node ("a", [Node ("b", []); Node ("c", [])])
))
let _ = assert (split (Node ((1, "a"), [])) = (Node (1, []), Node ("a", [])))