1

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. enter image description here

How would you implement this in scala? I do have some idea on how to start it using Java. Your help is appreciated.

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.