You have to program several functions. In each case, few lines of code are enough.
Write an integer function @count_diff(f)@ that given a list of integers returns the number of different values in the list.
Write a float function @product(u, v)@ that given two float lists representing two vectors returns the scalar product. You can assume both lists have the same length and are non empty.
Write a function @delete_multiples(k, f)@ that provided an integer greater than zero and a list of integers returns the list of numbers in that are not multiple of . Numbers in the resulting list must preserve their relative order in .
Write a function @erato(n)@ that returns the ordered list of prime numbers that are less than natural . Your code has to implement the algorithm known as Sieve of Eratosthenes. This algorithm is one of the most efficient ways to find all of the smaller primes. It is named after Eratosthenes of Cyrene, a Greek mathematician.
Write a function @merge(f, g)@ that provided two ordered list of integers and returns and ordered list of integers formed by elements of and . Warning: do not use any kind of sorting function.
Every function counts 20 points.
>>> count_diff([3, -1, 0, 3 ,2, 0]) 4 >>> product([1/3, 0, -1], [3/2, 1/2, 2]) -1.5 >>> delete_multiples(2, [6, 3, -2, -5, 7]) [3, -5, 7] >>> erato(30) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] >>> merge([1, 2, 5, 9], [-3, 0, 2, 11, 12, 13]) [-3, 0, 1, 2, 2, 5, 9, 11, 12, 13]