# Is there a way to specify a range for slicing that is bounded only on one side?I

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-specify-a-range-for-slicing-that-is-bounded-only-on-one-side-i/56392>\
**Category:** General Usage\
**Created:** [March 3, 2021, 9:37am UTC](https://discourse.julialang.org/t/is-there-a-way-to-specify-a-range-for-slicing-that-is-bounded-only-on-one-side-i/56392 "2021-03-03T09:37:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BridgeBot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bridgebot/32/21491_2.png) [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Post date:** [March 3, 2021, 9:37am UTC](https://discourse.julialang.org/t/is-there-a-way-to-specify-a-range-for-slicing-that-is-bounded-only-on-one-side-i/56392/1 "2021-03-03T09:37:49Z")

</div>

Is there a way to specify a range for slicing that is bounded only on one side?  
I can do `i = 1:10; a[i]` for bounded on both sides and I can do `i = Colon(); a[i]` for using the whole array.  
Is there a simple way to do something like `i = n:end; a[i]` ?  
Note that I want to reuse `i` for multiple arrays of potentially different length, so I can’t just write `i = n:lastindex(a)` .

Note that the original poster on Slack cannot see your response here on Discourse. Consider _transcribing the appropriate answer back to Slack_, or pinging the poster here on Discourse so they can _follow this thread_.  
[(Original message :slack:)](https://julialang.slack.com/archives/C6A044SQH/p1614764246254400?thread_ts=1614764246.254400&cid=C6A044SQH) [(More Info)](https://github.com/JuliaCommunity/SlackBridge)

---

<div class="post-metadata">

**Author:** ![JonasIsensee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonasisensee/32/4704_2.png) [@JonasIsensee](https://discourse.julialang.org/u/JonasIsensee)\
**Post date:** [March 3, 2021, 10:39am UTC](https://discourse.julialang.org/t/is-there-a-way-to-specify-a-range-for-slicing-that-is-bounded-only-on-one-side-i/56392/2 "2021-03-03T10:39:00Z")

</div>

> I don’t think such a thing exists - but maybe there’s a package I don’t know about. You can make your own `HalfOpenRange` type

> I seem to remember a simple package doing that

> Yeah, I just implemented this in my script. That works for now

```julia
struct LowerBoundedSlice
    i::Int
end
Base.getindex(x::T, l::LowerBoundedSlice) where {T<:AbstractArray}= x[filter(>=(l.i), axes(x,1))]

```

```julia
i = n:typemax(Int); a[i ∩ (begin:end)]

```

Other solutions:

> **[GitHub - JuliaArrays/EndpointRanges.jl: Julia package for doing arithmetic on...](https://github.com/JuliaArrays/EndpointRanges.jl)**
>
> Julia package for doing arithmetic on endpoints in array indexing - GitHub - JuliaArrays/EndpointRanges.jl: Julia package for doing arithmetic on endpoints in array indexing
