Re: [julia-users] Re: range bug in 0.4.1?

2015-12-07 Thread Jürgen Bohnert
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 whycrying:
>
> 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
>>
>
>
>
> -- 
> https://www.zhangkaizhao.com/
>


Re: [julia-users] Re: range bug in 0.4.1?

2015-12-07 Thread Tomas Lycken
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* don't 
have need for it, doesn't mean no-one else does :)

// T

On Monday, December 7, 2015 at 9:53:38 AM UTC+1, Jürgen Bohnert wrote:
>
> 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 whycrying:
>>
>> 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
>>>
>>
>>
>>
>> -- 
>> https://www.zhangkaizhao.com/
>>
>

Re: [julia-users] Re: range bug in 0.4.1?

2015-12-06 Thread Milan Bouchet-Valat
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 here. Also, you can replace div() with
the ÷ operator (written using "\div" then hitting Tab at the REPL).


Regards


Re: [julia-users] Re: range bug in 0.4.1?

2015-12-06 Thread whycrying
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  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/