progs/lecture1.scala
changeset 195 fc3ac7b70a06
parent 189 ff815ca0bbcf
child 199 54befaf23648
equal deleted inserted replaced
194:060b081523de 195:fc3ac7b70a06
   552 
   552 
   553 val large_string = randomString(3000000)
   553 val large_string = randomString(3000000)
   554 
   554 
   555 time_needed(10, santa_state(large_string))
   555 time_needed(10, santa_state(large_string))
   556 time_needed(10, santa_imutable(large_string))
   556 time_needed(10, santa_imutable(large_string))
       
   557 
       
   558 
       
   559 
       
   560 
       
   561 
       
   562 //=======================
       
   563 // equality is structural
       
   564 val a = "Dave"
       
   565 val b = "Dave"
       
   566 
       
   567 if (a == b) println("equal") else println("unequal")
       
   568 
       
   569 
       
   570 
       
   571 List.fill(10)(math.random)
       
   572 
       
   573 //------------------------
       
   574 
       
   575 
       
   576 for (a <- 0 to 10) {
       
   577   println(a)
       
   578 }
       
   579 
       
   580 for (a <- 0 until 10) {
       
   581   println(a)
       
   582 }
       
   583 
       
   584 for (a <- 0 until 2; b <- 0 to 2) {
       
   585   
       
   586 }
       
   587 
       
   588 output
       
   589 a=0, b=0
       
   590 a=0, b=1
       
   591 a=0, b=2
       
   592 a=1, b=0
       
   593 a=1, b=1
       
   594 a=1, b=2