Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program in SML (standard ML) You can use the following functions from the SML Basis Library, but not any others. http://sml-family.org/Basis/top-level-chapter.html http://sml-family.org/Basis/list.html http://sml-family.org/Basis/list-pair.html 3. (i)
Program in SML (standard ML)
You can use the following functions from the SML Basis Library, but not any others.
http://sml-family.org/Basis/top-level-chapter.html http://sml-family.org/Basis/list.html http://sml-family.org/Basis/list-pair.html
3. (i) Code a function follows ('a *'a ->bool) -> 'a listbool that returns true if and only if every pair of consecutive elements in the given list is in the given relation. (Notice that, if the given list is of length less than 2, this is trivially the case.) - follows op [1,3,2,8,3]; val it true; follows op [1,3,2,2,3]; val it false; -follows ops [1,2, 17, 235]; val it - follows op bool that checks if the given list of value and integer pairs is a valid compression, i.e., that, (a) in each such pair, the number component is non-0 (and also non-negative), and (b) in each two consecutive such pairs, the values components are different. - validCompr [(17, 3), (42, 5), (1011, 2)]; val it = true - validCompr [(17, 3), (2018, 0), (42, 5), (1011, 2)]; val it-false - validCompr [(17, 3), (42, 2), (42, 3), (1011, 2)]; val it false 3. (i) Code a function follows ('a *'a ->bool) -> 'a listbool that returns true if and only if every pair of consecutive elements in the given list is in the given relation. (Notice that, if the given list is of length less than 2, this is trivially the case.) - follows op [1,3,2,8,3]; val it true; follows op [1,3,2,2,3]; val it false; -follows ops [1,2, 17, 235]; val it - follows op bool that checks if the given list of value and integer pairs is a valid compression, i.e., that, (a) in each such pair, the number component is non-0 (and also non-negative), and (b) in each two consecutive such pairs, the values components are different. - validCompr [(17, 3), (42, 5), (1011, 2)]; val it = true - validCompr [(17, 3), (2018, 0), (42, 5), (1011, 2)]; val it-false - validCompr [(17, 3), (42, 2), (42, 3), (1011, 2)]; val it falseStep 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