1:10 creates a UnitRange which stores just two numbers, start and
stop:
julia> typeof(1:10)
UnitRange{Int64} (constructor with 1 method)
julia> names(UnitRange)
2-element Array{Symbol,1}:
:start
:stop
To actually create the list you'd use collect(1:10)
On Thu, 2015-03-12 at 14:19, Ali Rezaee <[email protected]> wrote:
> Hi,
>
> I am trying to iterate over a range of numbers. I know I can do this:
>
> for i in 1:10
> println(i)
> end
>
> but, if I am not wrong, it creates a list from 1 to 10 and iterates over it.
> Is there a more memory efficient method so that it does not create and
> store the list? something that returns an iterator object similar to
> Python's xrange().
>
> Many thanks