Question: Please code these the function uniq in OCaml language. DO NOT use recursion nor recursive (or non-recursive) helper methods. You are also not allowed to
Please code these the function uniq in OCaml language. DO NOT use recursion nor recursive (or non-recursive) helper methods. You are also not allowed to use List Library methods. Use only the provided funs.ml functions to program. You do not have to code is_present nor count_occ (I have already coded them).
.
Below is the functions, map, fold, and fold_right from funs.ml and their types.


Again, please DO NOT use recursion nor recursive (or non-recursive) helper methods. You are also not allowed to use List Library methods. If you do you will get a bad rating for your answer. And again, the only code you are required to code is uniq. Assume that is_present and count_occ is already coded and is working.
Write the following functions using map, fold, or fold_right as defined in the file funs.m1. You must use map, fold, or fold_right to complete these functions, so none of the functions in Part 4 should be defined using the rec keyword. You also may not create recursive helper functions. You will lose points if this rule is not followed. is_present lst x - Type: 'a list ' a int list - Description: Returns a list of the same length as 1 st which has a 1 at each position in which the corresponding position in 1 st is equal to x, and a otherwise. - Examples: \( \begin{aligned} \text { assert(is_present }[1 ; 2 ; 3] 1 & =[1 ; \theta ; \theta]) ; \\ \text { assert(is_present }[1 ; 1 ; \theta] \theta & =[0 ; \theta ; 1]) ; \\ \text { assert(is_present }[2 ; 0 ; 2] 2 & =[1 ; 0 ; 1]) ;\end{aligned} \) count_occ lst target - Type: 'a list ' a int - Description: Returns how many elements in lst are equal to target. - Examples: assert (count_occ [] 1=0);; assert ( count_occ [1]1=1);; assert(count_occ [1;2;2;1;3]1=2);; uniq lst - Type: 'a list 'a list - Description: Given a list, returns a list with all duplicate elements removed. Order does not matter, in the output list. - Examples: assert( uniq []=[]);; assert( uniq [1]=[1]);; assert( uniq [1;2;2;1;3]=[2;1;3])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
