progs/lecture1.scala
changeset 34 40424bbe109e
parent 33 b6cb302633eb
child 36 f5ed0fef41b3
equal deleted inserted replaced
33:b6cb302633eb 34:40424bbe109e
    21 
    21 
    22 // an element in a list
    22 // an element in a list
    23 val lst = List(1, 2, 3, 1)
    23 val lst = List(1, 2, 3, 1)
    24 lst(0)
    24 lst(0)
    25 lst(2)
    25 lst(2)
       
    26 
       
    27 // some alterative syntax for lists
    26 
    28 
    27 1::2::3::Nil
    29 1::2::3::Nil
    28 List(1, 2, 3) ::: List(4, 5, 6)
    30 List(1, 2, 3) ::: List(4, 5, 6)
    29 
    31 
    30 // Printing/Strings
    32 // Printing/Strings
    72 // Types
    74 // Types
    73 //=======
    75 //=======
    74 
    76 
    75 /* Scala is a strongly typed language
    77 /* Scala is a strongly typed language
    76  
    78  
    77  * Base types
    79  * some base types
    78 
    80 
    79     Int, Long, BigInt, Float, Double
    81     Int, Long, BigInt, Float, Double
    80     String, Char
    82     String, Char
    81     Boolean
    83     Boolean
    82 
    84 
    83  * Compound types 
    85  * some compound types 
    84 
    86 
    85     List[Int],
    87     List[Int],
    86     Set[Double]
    88     Set[Double]
    87     Pairs: (Int, String)        
    89     Pairs: (Int, String)        
    88     List[(BigInt, String)]
    90     List[(BigInt, String)]