Writing a scala function which can take Int or Double values
<p>I have written a function to accept the below type of values:
(1, Array(1.0,2.0,3.0)) 
That is a Tuple with Int being first value and next being an Array of Doubles.</p>

<p>I would also like it to accept an Array of Integers as well. The function I have written is as below:</p>

<pre><code>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)) 
}
</code></pre>

<p>The tuple's first parameter is a number and then its an Array of number of times it appears in the file.</p>

<p>It is working fine for sample cases, however I am reading a text file which has the data in the same format as needed for this function to work. I am calling this function using 'map' operation as:</p>

<pre><code>parsedfile.map(getCountsAndAverages)
</code></pre>

<p>I am getting the below errors:</p>

<pre><code>◾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.
</code></pre>

<p>I would be grateful for any help or suggestions</p>