CSE341 Section #3 Problems 1. Define a function called isPrime that takes an integer as a parameter and that returns true iff the integer is prime. The approach you should use is to verify that it has no factors in the range of 2 through its square root. First write it using a helper function that includes a named helper function isFactor and then write a second version using an anonymous function. 2. Define a function called sumOfSquares that takes a list of integers as a parameter and that returns the sum of the squares of the integers in the list. For example sumOfSquares([3, 4, 9]) should return 106 (3^2 + 4^2 + 9^2). Write it a a one-line function using map/filter/reduce and anonymous functions. 3. Define a function called sumOfSquares2 that takes an integer n as a parameter and that returns the sum of the squares of the integers 1 through n inclusive. For example, sumOfSquares2(5) should return 55 (1^2 + 2^2 + 3^2 + 4^2 + 4^2). Write it a a one-line function using map/filter/reduce and anonymous functions. 4. Define a function called oddProduct that takes an integer n as a parameter and that returns the product of the first n odd numbers. Write it a a one-line function using map/filter/reduce and anonymous functions. 5. Define a function len that computes the length of a list. Write it a a one-line function using map/filter/reduce and anonymous functions. 6. Define the following functions using val declarations involving curried functions and the function composition operator. You are not to define any helper functions using fun declarations or the "fn" anonymous function notation. a) Function double that takes an int and returns its double b) Function prependStar that takes a string as a parameter and that returns a new string with a star ("*") followed by the parameter. For example, prependStar("hello") should return "*hello". c) Function oneTo that takes an integer n as a parameter and that returns the list of integers from 1 to n inclusive. d) Function addOne that takes a list of integer values and that returns the list obtained by adding one to each number in the list. e) Function f that takes an integer n and that returns abs(2n + 10) f) Function primeProduct that takes a list of integers as a parameter and that returns the product of the primes in the list (you can use function isPrime from problem #1) 7. Each of the following definitions is flawed because it needs parentheses. Indicate how ML will group the items and where parentheses need to be added: a) fun f c:char = 1.0 b) fun f x::xs = [] c) print Int.toString 123 d) val add2 = map2 curry op+ 2