Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Haskell GHCI: Tail recursion and Datatypes PLEASE TRY TO ANSWER IT THIS TIME AS BEST POSSIBLE. 1. (8 points) Write a function common : :

Haskell GHCI: Tail recursion and Datatypes

PLEASE TRY TO ANSWER IT THIS TIME AS BEST POSSIBLE.

image text in transcribed

1. (8 points) Write a function common : : Eq a => [a] -> [a] -> ([a], [a], [a]) where common xy = (cp, x', y'), where cp is the longest common prefix of x and y, and x' and y' are x and y with cp removed. (I.e., x = cp ++x', y=cp ++y', and cp cannot be extended.) Example: if x is [1,3,5,7,9), and y is [1,3,5,8,9], then common x y is ([1,3,5],[7,9],[8,9]). Restriction: common should call an assistant tail recursive routine that implements a loop. Hint: You'll also want reverse somewhere. 1. (8 points) Write a function common : : Eq a => [a] -> [a] -> ([a], [a], [a]) where common xy = (cp, x', y'), where cp is the longest common prefix of x and y, and x' and y' are x and y with cp removed. (I.e., x = cp ++x', y=cp ++y', and cp cannot be extended.) Example: if x is [1,3,5,7,9), and y is [1,3,5,8,9], then common x y is ([1,3,5],[7,9],[8,9]). Restriction: common should call an assistant tail recursive routine that implements a loop. Hint: You'll also want reverse somewhere

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

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

e. What difficulties did they encounter?

Answered: 1 week ago