progs/lecture1.scala
changeset 148 ead6089209ba
parent 147 72f7dd1a3754
child 170 37b1bfcdba79
equal deleted inserted replaced
147:72f7dd1a3754 148:ead6089209ba
   257 
   257 
   258 for (n <- (1 to 3).toList; 
   258 for (n <- (1 to 3).toList; 
   259      m <- (1 to 3).toList;
   259      m <- (1 to 3).toList;
   260      if (n + m) % 2 == 0) yield (n, m)
   260      if (n + m) % 2 == 0) yield (n, m)
   261 
   261 
   262 
   262 for (n <- (1 to 3).toList; 
       
   263      m <- (1 to 3).toList;
       
   264      if ((n + m) % 2 == 0)) yield (n, m)
   263 
   265 
   264 // with patterns
   266 // with patterns
   265 
   267 
   266 for ((m, n) <- List((1, 4), (2, 3), (3, 2), (4, 1))) yield m + n 
   268 for ((m, n) <- List((1, 4), (2, 3), (3, 2), (4, 1))) yield m + n 
   267 
   269