title: Populating a list of case classes
body: <p>Here is a class I'm working on where I'm attempting to create a List of case classes of type : </p>
  
  <pre><code>case class Summary(mean : Double , std : Double, currency : String)
  </code></pre>
  
  <p>I calculate the <code>mean</code> and <code>stddev</code> using a map and filter, then zip the resultant lists to obtain : </p>
  
  <p><code>List((1.0,0.0), (1.0,0.0))</code> which corresponds to : </p>
  
  <pre><code>List((mean1,stddev1), (mean2,stddev2))
  </code></pre>
  
  <p>How to map these values to the case class <code>case class Summary(mean : Double , std : Double, currency : String)</code> ?</p>
  
  <p>Entire code : </p>
  
  <pre><code>package com.stats
  
  import com.data.OrderDetails.OrderInstance
  import java.util.Date
  import breeze.stats._
  
  class Statistics {
  
    case class Summary(mean : Double , std : Double, currency : String)
  
    def getStats(od : List[OrderInstance] , before : Date , after : Date) = {
  
      val dateInterval = od.filter(x =&gt; (x.time.before(before)
        &amp;&amp; x.time.after(after)))
  
      val curr : List[String] = List("BTC" , "LTC" )
  
      val meanCurrPrice : List[Double] = curr.map(c =&gt; mean(od.filter(x =&gt; x.code.equalsIgnoreCase(c))
        .map(m =&gt; m.price)))
  
      val stdCurrPrice : List[Double] = curr.map(c =&gt; stddev(od.filter(x =&gt; x.code.equalsIgnoreCase(c))
        .map(m =&gt; m.price)))
  
     meanCurrPrice.zip(stdCurrPrice)
    }
  
  }
  
  object Statistics {
  
    def main(args: Array[String]): Unit = {
  
      val od1 = new OrderInstance(1.0 , "" , 1 , 1.0 , new Date() , "BTC")
      val od2 = new OrderInstance(1.0 , "" , 1 , 1.0 , new Date() , "BTC")
      val od3 = new OrderInstance(1.0 , "" , 1 , 1.0 , new Date() , "LTC")
  
      //4 hours in the future
      val before : Date = new Date(new Date().getTime + (4 * 60 * 60 * 1000))
      //1444 hours in the past - to be sure!
      val after : Date = new Date(new Date().getTime - (1444 * 60 * 60 * 1000))
  
      val l  = List(od1 , od2 , od3)
  
      println(new Statistics().getStats(l , before , after))
    }
  
  }
  </code></pre>