Question: This is my ocaml code, it essentially takes a list and returns a list that contains the odd elements of the original list (1,3,5,7, etc.).

 This is my ocaml code, it essentially takes a list and

This is my ocaml code, it essentially takes a list and returns a list that contains the odd elements of the original list (1,3,5,7, etc.). It is currently of the form int list -> int list. I would like it to be of type 'a list -> 'a list. Any help would be appreciated.

'a list is just a list that can take any type, it could be an int list or a string list etc.

let oddnum n = n mod 2 != 0;; let rec everyOdd = function [ -> [l | h::t -> if oddnum h then h:: (everyOdd t) else everyOdd t let oddnum n = n mod 2 != 0;; let rec everyOdd = function [ -> [l | h::t -> if oddnum h then h:: (everyOdd t) else everyOdd t

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!