Monday, 21 September 2020

Scala: Get square root of numbers from 1 to 10

scala> import scala.math._
import scala.math._

scala> 1.to(10).map(sqrt(_))
val res51: IndexedSeq[Double] = Vector(1.0, 1.4142135623730951, 1.7320508075688772, 2.0, 2.23606797749979, 2.449489742783178, 2.6457513110645907, 2.8284271247461903, 3.0, 3.1622776601683795)

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment