title: Scala - convert Array[String] to Array[Double]
body: <p>I am a newbie to functional programming language and I am learning it in Scala for a University project. </p>
  
  <p>This may seem simple, but I am unable to find enough help online for this or a straightforward way of doing this - how can I convert an Array[String] to Array[Double]? I have a CSV file which, when read into the REPL is interpreted as String values (each line of the file has a mix of integer and string values) which would return a type Array[String]. I want to encode the string values with a double/int values to return Array[Double] in order to make the array homogeneous. Is there a straightforward way of doing this? Any guidance will be much appreciated.</p>
  
  <p>What I have done until now is:</p>
  
  <pre><code>def retrieveExamplesFromFile(fileName : String) : Array[Array[String]] = {
    val items = for {
      line &lt;- Source.fromFile(fileName).getLines()
      entries = line.split(",")
      } yield entries
  
    return items.toArray
  }
  </code></pre>
  
  <p>The format of each line (returned as String[]) is so:</p>
  
  <pre><code>[[1.0, 2.0, item1], [5, 8.9, item2],....]
  </code></pre>
  
  <p>And to convert each line in the CSV file into double array, I only have a psuedo definition drafted so:</p>
  
  <pre><code>def generateNumbersForStringValues(values : Array[String]) : Array[Double] = {
  val line = for(item &lt;- values)
  {
      //correct way?
      item.replace("item1", "1.0")
      item.replace("item2", "1.0")    
  } 
  return //unable to typecast/convert
  }
  </code></pre>
  
  <p>Any ideas are welcome. Thank you for your time.</p>