How to iterate over range with negative step?

virtualeyes picture virtualeyes · Nov 16, 2012 · Viewed 8.7k times · Source

Is there a way to do something like:

0 to -10 map { i=>
...
}

repl gives me:

scala.collection.immutable.IndexedSeq[Unit] = Vector()

Answer

Arjan picture Arjan · Nov 16, 2012
0 to (-10, -1)

or

0 to -10 by -1