progs/lecture2.scala
changeset 51 0e60e6c24b99
parent 39 c6fe374a5fca
child 53 9f8751912560
equal deleted inserted replaced
50:9891c9fac37e 51:0e60e6c24b99
       
     1 // Scala Lecture 2
       
     2 //=================
       
     3 
       
     4 
       
     5 // Option type
       
     6 //=============
       
     7 val lst = List(None, Some(1), Some(2), None, Some(3))
       
     8 
       
     9 lst.flatten
       
    10 Some(1).get
       
    11 
       
    12 val ps = List((3, 0), (3, 2), (4, 2), (2, 0), (1, 0), (1, 1))
       
    13 
       
    14 for ((x, y) <- ps) yield {
       
    15   if (y == 0) None else Some(x / y)
       
    16 }
       
    17 
     1 // sudoku
    18 // sudoku
     2 // some none
    19 // some none
     3 // pattern matching
    20 // pattern matching
     4 
    21 
     5 //type abbreviations
    22 //type abbreviations