Question: Please code in OCaml language. Given the type tree and the provided function tree_fold (fold tree), please code the function compose using tree_fold. DO NOT



Please code in OCaml language.
Given the type tree and the provided function tree_fold (fold tree), please code the function compose using tree_fold. DO NOT use recursion for this function. You can use helper functions, but do not make them recursive.
You can use stdlib module and List module library methods and NOTHING ELSE.
Again, please do not use recursion, and only use these 2 module libraries.
type 'a tree = | Node of 'a tree *'a 'a 'a tree Leaf let tree_fold f init tree = let rec aux = function Leaf init | Node (l,v,r)f(auxl)v( aux r) in aux tree let map tree f= let f facc lr= Node (l,fx,r) in tree_fold f facc Leaf tree compose tree - Type: (('a ' a ) tree 'a 'a) the in order composition of the nodes. You must implement this function using tree_fold. - Examples: Consider the following diagram of a tree. The rusult of calling compose on this function would be equivalent to ( fun xh(y(f(g(vx))))) let function_tree = Node ( Node(Leaf,(funx>x+1),Leaf))Node(Leaf,(funx>x+xx),Leaf))) \( \begin{aligned} \text { let composed } & =\text { compose function_tree } \\ \text { composed } 0 & =0 \\ \text { composed } 1 & =12 \\ \text { let composed2 } & =\text { compose Leaf } \\ \text { composed2 } 2 & =2 \\ \text { composed2 } 15 & =15\end{aligned} \)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
