In [1]:
println(s"""Details of exec env ==>
| ${util.Properties.versionMsg}
| ${util.Properties.javaVmName} ${util.Properties.javaVersion} ${util.Properties.javaVmVersion}"""
.stripMargin)
In [2]:
import math._
3 - pow(sqrt(3), 2)
Out[2]:
In [3]:
"crazy" * 3
Out[3]:
In [4]:
10 max 2
Out[4]:
In [5]:
BigInt(2).pow(1024)
Out[5]:
In [6]:
import util._
import BigInt._
probablePrime(100, Random)
Out[6]:
In [7]:
val title = "Scala for the Impatient"
// Java-style
println("Java-style:-")
println(s"\tFirst character: ${title(0)}")
println(s"\tLast character: ${title(title.length - 1)}")
// Scala-style
println("\nScala-style:-")
println(s"\tFirst character with head method: ${title.head}")
println(s"\tFirst character with take method: ${title.take(1)}")
println(s"\tFirst character with dropRight method: ${title.dropRight(title.length - 1)}\n")
println(s"\tLast character with tail method: ${title.tail(title.length-2)}")
println(s"\tLast character with drop method: ${title.drop(title.length - 1)}")
println(s"\tLast character with takeRight method: ${title.takeRight(1)}")