Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(int, float, bool, string) (a) Consider a function with polymorphic type f : a -> a -> a. What is the type of f 0

(int, float, bool, string)

(a) Consider a function with polymorphic type f : a -> a -> a.

What is the type of f 0 ?

What is the type of fun x -> (f f) x ? Briefly explain your reasoning.

(b) Consider a function with polymorphic type f : (a * b) -> (b -> a) -> a

What is the type of f (0, true) ?

What is the type of fun x y -> f (x, y) ? Does it have the same type as f ? Briefly explain your reasoning.

(c) Consider a function with polymorphic type g : (a -> b > b) -> b -> a.

What is the type of g (+)?

What is the type of fun x -> (g g) x ? Briefly explain your reasoning.

(d) Consider the following function.

image text in transcribed

Is it well typed? Briefly explain your reasoning.

let f (x : int list) : bool list match x with | [] -> x | hd :: tl -> true :: [] let f (x : int list) : bool list match x with | [] -> x | hd :: tl -> true :: []

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago