Question: write in ocaml you should use todo functions In this question we want you to find the largest item in a list of integers. You
write in ocaml
you should use todo functions
-
In this question we want you to find the largest item in a list of integers. You can assume that the lists are nonempty. The top level declaration is nonrecursive because there is an internal recursive function.
# let find_max l = ... val find_max : 'a list -> 'a =
# find_max [1; 6; 3; 2; 6; 1; 7; 2; 3; 5];; - : int = 7 Even though your code is polymorphic and should work on all types for which an order is defined (int, char, string) the grader will get confused if you try to give it a list containing items of different types. Please only test this on integer lists.
(* Q3 TODO: Write your own tests for the find_max function. *) let find_max_tests = [ (* Your test cases go here. *) ] (* (* Q3 TODO: Implement find_max. *) let find_max l = *)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
