Scala downwards or decreasing for loop?
scala> 10 to 1 by -1
res1: scala.collection.immutable.Range = Range(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
The answer from @Randall is good as gold, but for sake of completion I wanted to add a couple of variations:
scala> for (i <- (1 to 10).reverse) {code} //Will count in reverse.
scala> for (i <- 10 to(1,-1)) {code} //Same as with "by", just uglier.