Question: Please complete the following in ML programming, I got all other questions answered but stuck on these The book is Modern Programming Languages, a practical

 Please complete the following in ML programming, I got all other

Please complete the following in ML programming, I got all other questions answered but stuck on these The book is Modern Programming Languages, a practical solution, 2nd edition Exercise 2 Define a function member of type 'a that member (e,L)istrue ifand only if e is an element of the list L list -bool so 2 Some programmens caim that their ML peograms are so clearly written as to be "sell-documentin requiring no comments, Indeed, some pregrammers have made this claim for thweir code in jast abou every programming langage ever invented. But no program is ever as sell-documenting an i Exercise 4 Define a function repeats of type '"a 1ist bool so that repeats (1) is true if and only if the list L has two equal elements next to each other A: What does the following function, g do? fun g stuff- let fun f(nil,-ly] If (xccrest.y)- f(rest.yl e f (rest.cy) in f (stuff,nil) end; B: (For 2018, add 3 points) write a function, fatnx), that computes applying f n ti example, given the function p fun p p+1: then f2n (p.3.1) computes f1) 1+(1+(1+1)-4 (adding 1 to 1 3 times) 5 Write an ML function definition for each of the following functions Exercise Try to predict what polytype MI. will infer for each function. Then check your pre- diction using the ML language system. What is the polytype determined by ML.for each case? &Rg.xy)-gtx) Exercise 6 The following is a list of proposed changes to ML's type system All involve subtypes, which ML does not have.) For each one, give examples of ML expmessions that have type errors now, but would not have ty the proposed change, and explain what the major benefits and drawbacks of the proposed change would be pe errors with a. Make char a subtype of string. b. Make int a subtype of real Please complete the following in ML programming, I got all other questions answered but stuck on these The book is Modern Programming Languages, a practical solution, 2nd edition Exercise 2 Define a function member of type 'a that member (e,L)istrue ifand only if e is an element of the list L list -bool so 2 Some programmens caim that their ML peograms are so clearly written as to be "sell-documentin requiring no comments, Indeed, some pregrammers have made this claim for thweir code in jast abou every programming langage ever invented. But no program is ever as sell-documenting an i Exercise 4 Define a function repeats of type '"a 1ist bool so that repeats (1) is true if and only if the list L has two equal elements next to each other A: What does the following function, g do? fun g stuff- let fun f(nil,-ly] If (xccrest.y)- f(rest.yl e f (rest.cy) in f (stuff,nil) end; B: (For 2018, add 3 points) write a function, fatnx), that computes applying f n ti example, given the function p fun p p+1: then f2n (p.3.1) computes f1) 1+(1+(1+1)-4 (adding 1 to 1 3 times) 5 Write an ML function definition for each of the following functions Exercise Try to predict what polytype MI. will infer for each function. Then check your pre- diction using the ML language system. What is the polytype determined by ML.for each case? &Rg.xy)-gtx) Exercise 6 The following is a list of proposed changes to ML's type system All involve subtypes, which ML does not have.) For each one, give examples of ML expmessions that have type errors now, but would not have ty the proposed change, and explain what the major benefits and drawbacks of the proposed change would be pe errors with a. Make char a subtype of string. b. Make int a subtype of real

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!