Step parameter in range objects, like in Python?

535 views
Skip to first unread message

Ismael VC

unread,
Dec 8, 2013, 9:01:40 AM12/8/13
to julia...@googlegroups.com
Hello everyone!

Is there an easy way to do this in Julia? It doesn't seem like a syntax error but I don't know why I get this:

>>> for i in range(0:10:2):
...         print(i)
...
0
2
4
6
8


julia> for i = 0:10:2
              println(i)
        end
0

Thanks!



Stefan Karpinski

unread,
Dec 8, 2013, 9:05:18 AM12/8/13
to Julia Users
Try 0:2:10.

Ismael VC

unread,
Dec 8, 2013, 9:11:57 AM12/8/13
to julia...@googlegroups.com
Thank you Stefan, I get it now! I didn't see this in the documentation, I will help translate it to spanish by the way, once I finish my final exams! ;-)

Johan Sigfrids

unread,
Dec 8, 2013, 9:15:06 AM12/8/13
to julia...@googlegroups.com
I also stumbled on this when I first tried Julia. This really is something that ought to be brought up in the Noteworthy Differences from Python part of the manual.
Reply all
Reply to author
Forward
0 new messages