Question: Your responsibility in this homework is to explore functional programming, pattern matching, and higher-order functions. You will do this in the context of writing several

Your responsibility in this homework is to explore functional programming, pattern matching, and higher-order functions. You will do this in the context of writing several utility functions in Haskell. Write the following Functions in Haskell.  Your responsibility in this homework is to explore functional programming, pattern

Function frotoByNearness to generate a sorted list of consecutive pairs spanning a list of Integers. Write your function in point-free style by composing your froto function and the sortWith function. Sort such that the pair whose absolute difference is smallest appears first in the list. For example, frotoByNearness [1, 5, -3, 2](,5), (-3,2), (5,-3)1 Function nearestPair to yield from the list of Integers given as a parameter the consecutive pair whose elements are closest. Use composition and implement your function in point-free style. For example. nearestPair [1, 5, -3, 2]? (1,5) Function mapButLast that accepts a transformation function and a list, much like the builtin map, but it generates the new list by applying the function to all elements but the last. For example, mapButLast (+1) [1.5]? [2, 3, 4, 5, 5] Function implode that accepts a separator String and a list of Showable items. It concatenates the items together with intervening separators. For example, implode " , " [1 . . 3] ? " 1 , 2, 3" Use function composition, mapButLast, and partial function application to write this in nearly point-free style. (You should only need to name the first parameter.) Function normspace that accepts a String parameter and returns a String like the param- eter, but with all sequences of multiple spaces character reduced to one space character example, normspace "the.wee-dog--yipped" ? "the.wee, dog.yipped". Use function composition and the group function to write this in point-free style Function frotoByNearness to generate a sorted list of consecutive pairs spanning a list of Integers. Write your function in point-free style by composing your froto function and the sortWith function. Sort such that the pair whose absolute difference is smallest appears first in the list. For example, frotoByNearness [1, 5, -3, 2](,5), (-3,2), (5,-3)1 Function nearestPair to yield from the list of Integers given as a parameter the consecutive pair whose elements are closest. Use composition and implement your function in point-free style. For example. nearestPair [1, 5, -3, 2]? (1,5) Function mapButLast that accepts a transformation function and a list, much like the builtin map, but it generates the new list by applying the function to all elements but the last. For example, mapButLast (+1) [1.5]? [2, 3, 4, 5, 5] Function implode that accepts a separator String and a list of Showable items. It concatenates the items together with intervening separators. For example, implode " , " [1 . . 3] ? " 1 , 2, 3" Use function composition, mapButLast, and partial function application to write this in nearly point-free style. (You should only need to name the first parameter.) Function normspace that accepts a String parameter and returns a String like the param- eter, but with all sequences of multiple spaces character reduced to one space character example, normspace "the.wee-dog--yipped" ? "the.wee, dog.yipped". Use function composition and the group function to write this in point-free style

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!