Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(i) Code in SML a function replicate : ,a * int-) , a list that returns the list consisting of the given number of copies

image text in transcribed

(i) Code in SML a function replicate : ,a * int-) , a list that returns the list consisting of the given number of copies of the given value. (If the number is 0, the function must return the empty list.) replicate 17 3 val it = [17, 17, 17] : int list (ii) Code a function uncompress : ('a * int) list-) , a list that returns the list where each one of the given values is listed in the associsted number of copies. (Use replicate.) uncompress (17, 3), (42, 5). (1011, 2)1 val it 017, 17, 17, 42, 42, 42, 42, 42, 1011, 1011 int list (ii) Code a function maxsegsEq 'a list -> ('a liat) list that bresks the given list down into maximal segments of equal values. maxSegsEq 17, 17, 17, 42, 42, 42, 42, 42, 1011, 1011 val it [[17, 17. 17 [42, 42, 42, 42, 42], [101, 101: (int list) list iv) Code a function compress a list -> (a * int) list that returns the length and the replicated value of each of the maximum seqments of equl elements in the given list. Use maxSegsEq) -compress 117, 17, 17, 42, 42, 42, 42, 42. 1011, 1011 val it [(17, 3), (42, 5), (1011, 2)] : (int * int) list (i) Code in SML a function replicate : ,a * int-) , a list that returns the list consisting of the given number of copies of the given value. (If the number is 0, the function must return the empty list.) replicate 17 3 val it = [17, 17, 17] : int list (ii) Code a function uncompress : ('a * int) list-) , a list that returns the list where each one of the given values is listed in the associsted number of copies. (Use replicate.) uncompress (17, 3), (42, 5). (1011, 2)1 val it 017, 17, 17, 42, 42, 42, 42, 42, 1011, 1011 int list (ii) Code a function maxsegsEq 'a list -> ('a liat) list that bresks the given list down into maximal segments of equal values. maxSegsEq 17, 17, 17, 42, 42, 42, 42, 42, 1011, 1011 val it [[17, 17. 17 [42, 42, 42, 42, 42], [101, 101: (int list) list iv) Code a function compress a list -> (a * int) list that returns the length and the replicated value of each of the maximum seqments of equl elements in the given list. Use maxSegsEq) -compress 117, 17, 17, 42, 42, 42, 42, 42. 1011, 1011 val it [(17, 3), (42, 5), (1011, 2)] : (int * int) list

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

Express the number in terms of i. a. -36 b. -5 c. --16 d. -32

Answered: 1 week ago

Question

b. Explain how you initially felt about the communication.

Answered: 1 week ago