progs/lecture1.scala
changeset 143 11396c17cd8b
parent 140 ecec79b9ab25
child 147 72f7dd1a3754
equal deleted inserted replaced
142:6f4d8b5e6d80 143:11396c17cd8b
   121 println(">\n\n<")
   121 println(">\n\n<")
   122 println(""">\n<""")
   122 println(""">\n<""")
   123 println("""">\n<"""")
   123 println("""">\n<"""")
   124 
   124 
   125 /* in Java
   125 /* in Java
   126 val lyrics = "Sun dips down, the day has gone \n" +
   126 val lyrics = "Sun dips down, the day has gone. \n" +
   127              "Witches, wolves and giants yawn \n" +
   127              "Witches, wolves and giants yawn. \n" +
   128              "Queen and dragon, troll and gnome \n" +
   128              "Queen and dragon, troll and gnome: \n" +
   129              "Baddy buddies head for home"
   129              "tired buddies head for home"
   130 */ 
   130 */ 
   131 
   131 
   132 val lyrics = """Sun dips down, the day has gone
   132 val lyrics = """Sun dips down, the day has gone.
   133                 |Witches, wolves and giants yawn
   133                 |Witches, wolves and giants yawn.
   134                 |Queen and dragon, troll and gnome
   134                 |Queen and dragon, troll and gnome:
   135                 |Baddy buddies head for home""".stripMargin
   135                 |tired buddies head for home""".stripMargin
   136 
   136 
   137 println(lyrics)
   137 println(lyrics)
   138 
   138 
   139 
   139 
   140 // Pairs/Tuples
   140 // Pairs/Tuples
   169 
   169 
   170 
   170 
   171 // If-Conditionals
   171 // If-Conditionals
   172 //=================
   172 //=================
   173 
   173 
   174 def fact(n: Int): Int = 
   174 def fact(n: Int) : Int = 
   175   if (n == 0) 1 else n * fact(n - 1)
   175   if (n == 0) 1 else n * fact(n - 1)
   176 
   176 
   177 
   177 
   178 fact(5)
   178 fact(5)
   179 fact(150)
   179 fact(150)