ocaml

Whenever a problem has an occurrence of …* 0 -> .., this effectively splits the problem in two: after the multiplication there is guaranteed to be a O, so errors aren’t propagated: a corrector will have to check both halves separately. Write a function to split the problem in two if there is an occurrence of Mult (-0). Therefore, you do not need to care about the case Mult (Int 0, -).The first half will end just before the * 0, and the second half will pick up with O as a starting value:
splitonMultzero CMult CPlus CMult (pLus CCInt 3), 15), 0),2),1))
Some (Plus CInt 3, 15),Mult CPlus (Int Q, 2),1)3
[Note, the first member of the pair is: Plus(Int 3, 15)
The second member of the pair is: Mult (Plus (Int 0, 2), 1)]
(splitonMultzero CMult ult C Mult CCInt 3), 0), 0), 0))
= Some (Mult (Mult (Int 3, 0), 0), Int 0)
[Note, the first member of the pair is: Mult (Mult (Int 3, 0), 0)
The second member of the pair is: Int O
(splitonMultzero cMult CPlus CPlus cMult CInt 3, 15),0),2),1))

Given the splitOnMultZero function, we can write a function that splits the exercise to a list of essentially different exercises. We’ll call this function keepSplitting:
keepSplitting (Mult CPlus CMuilt CPlus CInt 3, 15), 0),2),1))
= [Plus (Int 3, 15); Mult (Plus (Int 0, 2), 1)]
keepSplitting CMult cult CMult CInt 3, 0), 0), 0)
= [Int 3; Int 0; Int 0; Int 0]
keepsplitting cMult CPlus (Plus Cult CInt 3, 15), 0),2),1)))
= [Cult (Plus (Plus (Mult (Int 3, 15), 0), 2), 1))]
We have now created enough functions in order to efficiently create a list of nontrivial exercises that we can effectively present and also show how to procedurally solve automatically.
We put all the separate functions together in one big new function
(genProblems: [int] -> [bool] -> ( which takes a list of integers and booleans to generate a large exercise. It is then split and printed into nontrivial exercises, each of which is printed together with its corresponding solution. The function (genProblems is written for you; it is moreso to illustrate the culmination of the other functions you have designed and how you would use them in a classroom setting.
genProblems [1;2;0;3;4;0;5;6] [true;false; true; true; false;true; false];;

genProblems [1;2;0;3;4;0;5;6] [true;false;true; true; false; true; false];;
6 + 5 -> 11
0 + 4 →> .. * 3 →> .
0+4->4*3->12
0 + 2 -> 2
These are the functions you have to write and their corresponding types. You are always welcome to define additional helper functions.
Below the gradescope link is a scaffold for this homework that has the right types such that it will pass the compilation check in the autograder (it uses Failure as the implementation everywhere except for genProblems, so you’ll need to replace those).
The following link takes you to the gradescope assignment E.