Question: Please code these 3 functions in OCaml language. DO NOT use recursion nor outside helper methods . There is also a limit to list library

Please code these 3 functions in OCaml language. DO NOT use recursion nor outside helper methods. There is also a limit to list library methods, and the only ones you are allowed to use are: reverse list and merge.

Please code these 3 functions in OCaml language. DO NOT use recursion

The functions from funs.ml is provided below, along with the typing for each function and their parameter.

nor outside helper methods. There is also a limit to list librarymethods, and the only ones you are allowed to use are: reverse

I understand this is a lot to take in and very hard to code, especially with the restrictions spoken above, but please help me with them.

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

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!