Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 tStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started