# \[ANN\] Announcing RangeHelpers.jl

**URL:** <https://discourse.julialang.org/t/ann-announcing-rangehelpers-jl/62681>\
**Category:** Package Announcements\
**Created:** [June 10, 2021, 2:53pm UTC](https://discourse.julialang.org/t/ann-announcing-rangehelpers-jl/62681 "2021-06-10T14:53:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [June 10, 2021, 2:53pm UTC](https://discourse.julialang.org/t/ann-announcing-rangehelpers-jl/62681/1 "2021-06-10T14:53:27Z")

</div>

Ever needed a range with startpoint 10, endpoint 121.7 and a step of 25?  
Well that is mathematically not possible, so you need to compromise.  
There are lots of options, you could relax the startpoint, endpoint or step. In the past doing this was annoying and prone to off-by-one-errors:

```julia
julia> Base.range(10, step=25, length=round(Int, (121.7-10)/25)); # is it correct??

```

[RangeHelpers.jl](https://github.com/jw3126/RangeHelpers.jl) aims to solve range construction headaches once and for all:

```julia
julia> using RangeHelpers: range

julia> using RangeHelpers

julia> range(start=10, stop=121.7, step=around(25)) # compromise on step
10.0:27.925:121.7

julia> range(start=10, stop=121.7, step=below(25)) # compromise step at most 25
10.0:22.34:121.7

julia> range(start=10, stop=above(121.7), step=25) # exact step, but allow bigger endpoint
10:25:135

julia> anchorrange(42, start=around(10), step=25, stop=around(121.7)) # make sure 42 is on the grid
17.0:25.0:117.0

```

See [the documentation](https://jw3126.github.io/RangeHelpers.jl/dev/) for even more ways to make ranges.

---

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [June 10, 2021, 3:29pm UTC](https://discourse.julialang.org/t/ann-announcing-rangehelpers-jl/62681/2 "2021-06-10T15:29:29Z")

</div>

Nice concept!

One thing that came to my mind: Exporting functions with common names like `above`, `around`, etc. has a high conflict potential with other packages and local names. Just a suggestion - how would you like

```julia
range(start=10, stop=121.7, step=(≈,25))
range(start=10, stop=121.7, step=(<,25))

```

or so?

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [June 10, 2021, 3:45pm UTC](https://discourse.julialang.org/t/ann-announcing-rangehelpers-jl/62681/3 "2021-06-10T15:45:21Z")

</div>

> One thing that came to my mind: Exporting functions with common names like `above` , `around` , etc. has a high conflict potential with other packages and local names.

Absolutely! Personally I use `import X as Y` a lot:

```julia
import RangeHelpers as RH
RH.range(start=RH.below(4), step=2, stop=3)

```

The syntax you suggest is pretty clever, feel free to open a PR!

---

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [June 10, 2021, 4:00pm UTC](https://discourse.julialang.org/t/ann-announcing-rangehelpers-jl/62681/4 "2021-06-10T16:00:13Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 10, 2021, 4:09pm UTC](https://discourse.julialang.org/t/ann-announcing-rangehelpers-jl/62681/5 "2021-06-10T16:09:44Z")

</div>

Or make those modifiers types and then there is no conflict (and I bet some benefit to the speed?).
