Question: please write the two following functions in OCaml language contains_elem Ist e Type: 'a list -> 'a -> bool Description: Returns true if e is

please write the two following functions in OCaml language contains_elem Ist eplease write the two following functions in OCaml language

contains_elem Ist e Type: 'a list -> 'a -> bool Description: Returns true if e is present in the list ist, and false if it is not. Examples: assert(contains_elem [] 1 = false);; assert(contains_elem [1;2;3] 4 = false);; assert(contains_elem [1;2;3;3;2;4] 2 = true);; @is_present lst x Type: 'a list -> 'a -> int list Description: Returns a list of the same length as ist which has a 1 at each position in which the corresponding position in Ist is equal to x, and a 0 otherwise. Examples: assert(is_present [1;2;3] 1 assert(is_present [1;1;0] 0 = assert(is_present [2;0;2] 2 [1;0;0]);; [0;0;1]);; [1;0; 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!