1. The Scala interpreter reads an expression, evaluates it, prints it out, and then continues reading the next expression. This process is called "read-evaluate-print-loop", or REPL.
Exercises
1. Type 3 in the Scala repl, and then press the TAB key. What are the methods that can be applied.
I was typing "3." Press the TAB key to have the following output
2. In Scala repl, calculate the square root of 3 and then square the value, now, how much difference does this result have with 3? (Hint: res variable is your friend)
Import Scala.math._ First (the underscore indicates a wildcard character)
3. The res variable is Val or var.
I think it's Val.
4. Scala allows you to use numbers to multiply strings----go to Repl to try "crazy", what this operation does. How to find this operation in Scaladoc
Repeat Crazy 3 times
Search for string directly in Scaladoc
What is the meaning of 5.10 Max 2. The Max method is defined in which class.
Richint Class (Why direct search Max not found, not good)
6. Use bigint to calculate 2 of the 1024-time Square
7. What you need to introduce in order to use any qualifiers before probableprime and Radom to get random primes using probableprime (random).
Import Scala.util._
Import Scala.math.bigint._
Online search for, do not know why ...
8. One way to create a random file is to generate a random bigint, then convert it to 36, output a string like "Qsnveffwfweq434ojjlk", consult the Scaladoc, and find a way to implement that logic in Scala.
9. How to get the first and trailing characters of a string in Scala.
Take, Drop, takeright, dropright What are these string functions for? Compared with substring, they have the advantages and disadvantages.
(1) in the Stringlike
Take:selects first n elements. (select n characters at the beginning)
Takeright:selects last n elements. (select n characters at the end)
(2) Stringops
Drop:selects all elements except first n ones. (select n characters except the beginning)
Dropright:selects all elements except last n ones. (Select n characters in addition to the end)
(3) StringBuilder
SUBSTRING: Select the substring, which is to construct a new string