Question: Assume that the data type tree is defined as in problem 4. Write a function that combines all the values of the leaves by using

Assume that the data type tree is defined as in problem 4. Write a function that combines all the values of the leaves by using the binary operation passed as a parameter. In more detail, if oper : a * a ? a and t is the nonempty tree on the left in this picture,

Assume that the data type tree is defined as in problem 4.

then reduce oper t should be the result we obtain by evaluating the tree on the right. For example, if f is the function: fun f(x : int, y : int) = x + y;

then reduce f (NODE( NODE( LEAF 1, LEAF 2), LEAF 3)) = (1 + 2) + 3 = 6. Explain the definition of reduce in one or two sentences.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!