Answered step by step
Verified Expert Solution
Link Copied!

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.).

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How does PERT network analysis work?

Answered: 1 week ago

Question

The graph of f -1 is a reflection of the graph of f across y = 0.

Answered: 1 week ago