Answered step by step
Verified Expert Solution
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
(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
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