Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribed

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

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

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago