For two multi-track trees t1 and t2 defined with
type Forest a = [Tree a] data Tree a = Node { rootLabel :: a, subForest :: Forest a }
how can I write a function that removes a subtree from t1 and inserts it into the given node in t2?
I guess the signature will look something like
moveSubTree :: ((Tree xa) x (Tree xa)) -> (Tree x Tree)
i.e. requires a tree and a parent node that define the subtree to be deleted, and a second tree and node that defines the point at which to insert the original subtree.
If necessary, separate functions can be created for deletion, and then adding a subtree.
function types functional-programming recursion haskell
Rich ashworth
source share