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:
> range(stop) -> range object
> range(start, stop[, step]) -> range object
>
> Return a sequence of numbers from start to stop by step.
> Type:      type
>

On Sun, Dec 6, 2015 at 5:58 PM, Eric Forgy <eric.fo...@gmail.com> wrote:

> Another thing I've found helpful to understand these things in addition to
> "help" is "which":
>
> julia> which(range,(Int,Int))
> range(a::Real, len::Integer) at range.jl:84
>
> I guess you are expecting the second argument to be the "stop" point, but
> it is the length of the range.
>
> julia> length(range(2,5))
> 5
>
> julia> length(2:5)
> 4
>
> I sometimes even look at the source code that "which" points to in order
> to help understand what the function is actually doing.
>



-- 
https://www.zhangkaizhao.com/

Reply via email to