I wrote a function to accept the following types of values: (1, Array (1.0, 2.0.0.0)) This is a tuple with the first Int value and the next array of paired numbers.
I would also like it to accept an array of integers. The function I wrote is as follows:
def getCountsAndAverages[T](Parameter: Tuple2[Int, Array[T]])(implicit n:Numeric[T]) = { (Parameter._1, (Parameter._2.size, Parameter._2.map(n.toDouble).sum/Parameter._2.size)) }
The first parameter of the tuple is the number, and then its array from the number of times it appears in the file.
It works great for examples, but I am reading a text file that has data in the same format that is needed for this function to work. I call this function using the "map" operation:
parsedfile.map(getCountsAndAverages)
I get the following errors:
◾could not find implicit value for parameter n: Numeric[T] ◾not enough arguments for method getCountsAndAverages: (implicit n: Numeric[T])(Int, (Int, Double)). Unspecified value parameter n.
I would be grateful for any help or suggestions.
scala
Sumb
source share