Question: 1. Basic Function Please define the following functions in Haskell. TI 11 (a) Function sumSquares that, given a nonnegative integer n, returns 2 Type: (Eq

 1. Basic Function Please define the following functions in Haskell. TI

1. Basic Function Please define the following functions in Haskell. TI 11 (a) Function sumSquares that, given a nonnegative integer n, returns 2 Type: (Eq p, Num p) => p -> P Examples: sumSquares 4 = 30 sumSquares 5 - 55 (b) Function listDup that takes a pair, which consists of an element, e, of any type, and a non-negative number 1, as input and returns a list with n copies of e. Type: (Eq b, Num b) => (a, b) => [a] Examples: listDup ("moo", 4) = ["moo", "moo", "moo", "moo"] listDup (1,2) [1,1] listDup (listDup ("cow", 2), 2) - [{"cow", "Cow"],["cow", "Cow"]] 2. Recursion on lists Please define the following functions in Haskell. (a) Function getEvens takes a list of integers as input and returns a list by keeping only the elements that are even in their original order. Type: Integral a => [a] -> [a] Examples: getEvens (1,2,3,4,8,5,2] [2,4,8,2] (b) Function incBy takes a list of integers I and an integer n as input and returns a list by increasing every element in l by n. Type: Num a => a => [a] -> [a] Examples: incBy 5 [2,4,7) [7,9,12]

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!