Question: Haskell Code 1. Use the function filter in order to define a function dividers :: Int -> [Int] -> [Int] so that dividers n I

Haskell Code

Haskell Code 1. Use the function filter in order to define a

1. Use the function filter in order to define a function dividers :: Int -> [Int] -> [Int] so that dividers n I contains the elements from / that evenly divide n. Example: dividers 36 [1..18][1,2,3,4,6,9,12,18] 2. Use the function map in order to define a function replace :: Int Int -> [Int] -> [Int] so that replace m n l replaces every occurrence of m in l by n Example: replace 5 2 [2,5,5,3,5,61 [2,2,2,3,2,6 3. Using the higher-order function foldr define a function sumsq which takes an integer n as its argument and returns the sum of the squares of the first n integers. That is to say, Do not use the function map. Using a lambda abstraction, the Boolean function not and the built-in 4. function elem describe a function of type Char-> Bool which is True only on non-whitespace characters, that is those which are not elements of the list " \t ". 5. Define a function total total :: (Integer -> Integer) -> (Integer -> Integer) so that total f is the function which at value n gives the total You should be able to do this using built-in functions, rather than using recursion. 1. Use the function filter in order to define a function dividers :: Int -> [Int] -> [Int] so that dividers n I contains the elements from / that evenly divide n. Example: dividers 36 [1..18][1,2,3,4,6,9,12,18] 2. Use the function map in order to define a function replace :: Int Int -> [Int] -> [Int] so that replace m n l replaces every occurrence of m in l by n Example: replace 5 2 [2,5,5,3,5,61 [2,2,2,3,2,6 3. Using the higher-order function foldr define a function sumsq which takes an integer n as its argument and returns the sum of the squares of the first n integers. That is to say, Do not use the function map. Using a lambda abstraction, the Boolean function not and the built-in 4. function elem describe a function of type Char-> Bool which is True only on non-whitespace characters, that is those which are not elements of the list " \t ". 5. Define a function total total :: (Integer -> Integer) -> (Integer -> Integer) so that total f is the function which at value n gives the total You should be able to do this using built-in functions, rather than using recursion

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!