Why would one assume that the default step size is -1 when the start is bigger than the stop? The documentation for ranges clearly says that the default step size is 1 unconditionally, not that it is sign(stop-start). That would, by the way, be a very dangerous behavior. Perhaps a sidebar on the colon syntax is warranted in the manual control flow section on for loops, including examples of empty ranges and ranges that count downwards.
On Wed, Jul 2, 2014 at 9:53 AM, Jay Kickliter <[email protected]> wrote: > I just realized that it works if I rewrite the range as 10:-1:1. It seems > to me that either big:small should work with a default step size of -1, or > the documentation needs a note. > > > On Wednesday, July 2, 2014 7:32:10 AM UTC-6, Jay Kickliter wrote: >> >> Are they meant to work? I could only find one meaning of them not working >> (issue 5778 <https://github.com/JuliaLang/julia/issues/5778>). >> >> Here's an example: >> >> julia> for i = 1:10 >> >> println(i) >> >> end >> >> 1 >> >> 2 >> >> 3 >> >> 4 >> >> 5 >> >> 6 >> >> 7 >> >> 8 >> >> 9 >> >> 10 >> >> >> julia> for i = 10:1 >> >> println(i) >> >> end >> >> >> julia> >> >
