Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Haskell Identify the base case, and what the function should return in that case. In the recursive case, identify how knowing the result of

image text in transcribed

Using Haskell

Identify the base case, and what the function should return in that case. In the recursive case, identify how knowing the result of calling the function recursively on the tail of the list will enable you to compute the answer for the entire list.

6. removeEvens :: [Integer] -> [Integer] removes all even elements from the given list. EG, removeEvens [0,1,2,2,3,3,3,4] [1,3,3,3]. 7. doubleAll :: [Integer] -> [Integer] multiplies all entries in the list by 2: doubleAll (1,2,300] = [2,4,600] 8. flatten :: [[a]] -> [a] takes a list of lists, and returns a single list in which all the smaller lists have been concatenated together. flatten [[1,2,3] , [5,9] , [7,-1]] = [1,2,3,5,9,7,-1] flatten ("hello", "new","world"] = "hellonewworld" 9. countInt :: Integer -> [Integer] -> Integer, where countInt n 1 returns the number of times the integer n occurs in list 1. countInt 2 (1,2,3,4,3,2,1,2] 10. countEq :: Eq a => a => [a] -> Integer, similar to the above, but general- ized to work for any type which implements the equality predicate countEq 2 (1,2,3,4,3,2,1,2] = 3 countEq "the" ["the", "dog", "barked","at","the", "cat"] = 2 = 3 == 6. removeEvens :: [Integer] -> [Integer] removes all even elements from the given list. EG, removeEvens [0,1,2,2,3,3,3,4] [1,3,3,3]. 7. doubleAll :: [Integer] -> [Integer] multiplies all entries in the list by 2: doubleAll (1,2,300] = [2,4,600] 8. flatten :: [[a]] -> [a] takes a list of lists, and returns a single list in which all the smaller lists have been concatenated together. flatten [[1,2,3] , [5,9] , [7,-1]] = [1,2,3,5,9,7,-1] flatten ("hello", "new","world"] = "hellonewworld" 9. countInt :: Integer -> [Integer] -> Integer, where countInt n 1 returns the number of times the integer n occurs in list 1. countInt 2 (1,2,3,4,3,2,1,2] 10. countEq :: Eq a => a => [a] -> Integer, similar to the above, but general- ized to work for any type which implements the equality predicate countEq 2 (1,2,3,4,3,2,1,2] = 3 countEq "the" ["the", "dog", "barked","at","the", "cat"] = 2 = 3 ==

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago