Question: b) Write a tail-recursive polymorphic function with this signature: def countWitheconectx[T](X$: List[T], p: T => Boolean) : Int that returns the number of elements x

 b) Write a tail-recursive polymorphic function with this signature: def countWitheconectx[T](X$:

b) Write a tail-recursive polymorphic function with this signature: def countWitheconectx[T](X$: List[T], p: T => Boolean) : Int that returns the number of elements x from list xs for which p(x) is true. For example: xal lucky Numbers = List(4, 8, 15, 16, 23, 42) val evenCount = countWithProperty (lucky Numbers, (x: Int) => x % 2 == 0) The value of variable evenCount is 4. c) Write a tail-recursive function with this signature: def scalare.reduct(x: Array[Double], y: Array[Double]) : Double that returns the scalar product of arrays x and y. For example: xal xxes = Array(-1.0, -2, 3) val xxes = Array(2.0, -3, 1) xal prod = scalarproduct(xvec, yves) = // prod == 7 b) Write a tail-recursive polymorphic function with this signature: def countWitheconectx[T](X$: List[T], p: T => Boolean) : Int that returns the number of elements x from list xs for which p(x) is true. For example: xal lucky Numbers = List(4, 8, 15, 16, 23, 42) val evenCount = countWithProperty (lucky Numbers, (x: Int) => x % 2 == 0) The value of variable evenCount is 4. c) Write a tail-recursive function with this signature: def scalare.reduct(x: Array[Double], y: Array[Double]) : Double that returns the scalar product of arrays x and y. For example: xal xxes = Array(-1.0, -2, 3) val xxes = Array(2.0, -3, 1) xal prod = scalarproduct(xvec, yves) = // prod == 7

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!