fork download
  1. case class Life (age:Int) extends Component
  2.  
  3. object Main extends Component{
  4. def main(args: Array[String]){
  5. val lives = List(Life(10), Life(20), Life(30))
  6. def livesMean (l:List[Life]):Double = {
  7. val avg = lives.map(_.age).sum/lives.size
  8.  
  9. avg
  10. }
  11. println("average of lives "+ livesMean(lives))
  12. }
  13.  
  14.  
  15. }
Success #stdin #stdout 0.38s 4382720KB
stdin
Standard input is empty
stdout
average of lives 20.0