Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Haskell Code 1. Use the function filter in order to define a function dividers :: Int -> [Int] -> [Int] so that dividers n I
Haskell Code
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 recursionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started