yes an interval would be a reasonable solution, so one could read the colon operator as a generator which defines an interval and a step.
The 0,4 example was more a throwaway as it is an inexact comparison. On Tuesday, May 26, 2015 at 4:31:09 PM UTC-4, Stefan Karpinski wrote: > > What you're looking for seems to be some kind of interval type, which > doesn't ship with Julia but would be easy to make. I did a simple version > of this here: > > > http://nbviewer.ipython.org/gist/StefanKarpinski/b8fe9dbb36c1427b9f22#Interval-Arithmetic > > Googling shows up a few other implementations of interval types – maybe we > should have a common one that other packages can build on. The r object > you've constructed doesn't quite hit 0.4 exactly: > > julia> searchsorted(r,0.4) > 1801439850948200:1801439850948199 > > julia> r[1801439850948200] > 0.40000000000000013 > > julia> r[1801439850948199] > 0.3999999999999999 > > > Discrete ranges are trickier and more subtle than one can imagine before > getting into it. > > On Tue, May 26, 2015 at 4:17 PM, Michael Francis <[email protected] > <javascript:>> wrote: > >> Given that >> >> 0:10 >> >> Defines the set of all integer values inclusive of 0 and 10 >> >> 10 in 0:10 == true >> >> With floating point numbers the range >> >> 0.0:10.0 >> >> turns out to *not *define the range of all numbers inclusive of 0.0 and >> 10.0 but the stepped range with step size 1.0 >> >> 0.5 in 0.0:10.0 == false >> >> implicit in the overload of the : operator is a step of 1.0 so >> >> 1.0 in 0.0:10.0 == true >> >> collect( 0.0:10.0) >> >> 11-element Array{Float64,1}: >> 0.0 >> 1.0 >> 2.0 >> 3.0 >> 4.0 >> 5.0 >> 6.0 >> 7.0 >> 8.0 >> 9.0 >> 10.0 >> >> I'm assuming this the intended behavior? Is there a continuous Range >> available? The following fails >> >> r = 0.0:eps(Float64):10.0 >> >> 0.4 in r == false >> >> >> >> >> >> >> >> >
