I think it makes perfect sense. If you need a range object where you know
the start and ending points, you use colon (i.e. `start:step:stop`). If you
know how many elements you want and what step, but you don't know (or care
so much) about the stopping point, you use `range`. Just because *you*
I honestly cannot imagine a good application justifying this 'range'
function being in the main namespace. What it does is quite
counter-intuitive. Or maybe renaming it would be an option?
Anyway thanks for all your answers guys.
Best,
Juergen
Am Montag, 7. Dezember 2015 04:11:07 UTC+1 schrieb
Ah. The second argument is the length of the range.
And the three arguments's:
julia> which(range,(Int,Int,Int))
> range{T,S}(a::T, step::S, len::Integer) at range.jl:101
>
Not so consistent.
Well, this is different from Python.
Look range in Python(via iPython):
In [3]: range?
> Docstring:
>
Le dimanche 06 décembre 2015 à 01:03 -0800, 'Greg Plowman' via julia
-users a écrit :
> What about using integer division with div(), and colon operator to
> construct range?
>
> julia> N = 2^3-1
> 7
>
> julia> imid = div(N+1,2)
> 4
>
> julia> imid-2 : imid+2
> 2:6
Yes, that's the best solution