Ranges are a more compact representation of vectors with evenly spaced
elements:
julia> xdump(1:5:1000)
StepRange{Int64,Int64}
start: Int64 1
step: Int64 5
stop: Int64 996
i.e. it only uses 3 numbers instead of 200 (for this example). Anyway,
you should be able to use a range just like any other Vector as long as
you only read from it. (It is a bug if a function of Julia-Base works
with a Vector but not a Range in a read-only context (please report
it).)
If you need to write to it, you need to convert it to a normal vector
first:
v = collect(1:10)
This does trip up new users though, see e.g. this long thread:
https://groups.google.com/d/msg/julia-users/qPqgJS-usrU/Hu40_tOlDQAJ
On Mon, 2016-02-01 at 01:29, Li ly <[email protected]> wrote:
> Hello, fellows,
>
> One question I feel a bit confused is why there is UnitRange/FloatRange
> since we have Array in Julia.
>
> cheers,
>
> Yungui