Question: pls quick that's all the information i was given, this is coding in ocaml so please help Define a function count_some_tree of type 'a option

pls quick

pls quick that's all the information i was given, this is coding

that's all the information i was given, this is coding in ocaml so please help

Define a function count_some_tree of type 'a option tree -> int in hw4_trees.ml such that count_some_tree t returns the number of elements in the tree t that are tagged by some. If the tree t is empty, then the result is zero. For example, count_some_tree Leaf ===> 0 count_some_tree (Branch (Leaf, None, Leaf)) ===> count_some_tree (Branch (Leaf, Some 2.0, Leaf)) ===> 1 count_some_tree (Branch (Leaf, Some "hi", Branch (Branch (Leaf, Some "lo w", Leaf), None, Branch (Leaf, None, Leaf)))) ===> 2 Your function will probably be a recursive one. Feel free to add the rec keyword. (This applies to the rest of the homework assignment.) Note: if an element is tagged with multiple layers of Some, such as some (Some (Some 1)), it is still counted as one element tagged with some ). In fact, the typing constraints made it impossible for you to look beyond the first level of tagging. Think about why. 1

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!