Question: pls quick sorry programming language is ocaml Define a function sum_list_tree of type int list tree -> int in hw4_trees.ml such that sum_list_tree t returns

 pls quick sorry programming language is ocaml Define a function sum_list_tree

pls quick

sorry programming language is ocaml

Define a function sum_list_tree of type int list tree -> int in hw4_trees.ml such that sum_list_tree t returns the summation of all numbers in the tree t. The function is similar to sum_tree mentioned in the lectures except that each element is now a list of numbers instead of just one single number. If there are no numbers in the tree t, possibly because all elements are the empty list, then the function should return the zero. For example, sum_list_tree Leaf ===> 0 sum_list_tree (Branch (Leaf, [], Leaf)) ===> 0 sum_list_tree (Branch (Leaf, [100], Leaf)) ===> 100 sum_list_tree (Branch (Leaf, (1;2), Branch (Branch (Leaf, [], Leaf), [3; 4), Branch (Leaf, [5], Leaf)))) ===> 15 Again, add the rec keyword to the binding if you want to

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!