Reputation: 361
I am in the process of self teaching myself scala. I know java but I'm having a little problem implementing certain programs with scala.
I am reading a book specifically for learning scala and I'm trying to attempt one of the exercises for expanding my knowledge.
How would you implement this in scala? I do have some idea on how to start it using Java. Your help is appreciated.
Upvotes: 1
Views: 93
Reputation: 8866
I think you need something like this:
evalMono(mono: (Double, Double), x:Double) = mono._1 * Math.pow(x, mono._2)
evalPoly(poly: List[(Double, Double), x:Double) = poly.map (item => evalMono(item, x)).sum
Upvotes: 2