# Is there a version of "enumerate" in the reverse order?

**URL:** <https://discourse.julialang.org/t/is-there-a-version-of-enumerate-in-the-reverse-order/38374>\
**Category:** General Usage\
**Created:** [April 28, 2020, 2:31pm UTC](https://discourse.julialang.org/t/is-there-a-version-of-enumerate-in-the-reverse-order/38374 "2020-04-28T14:31:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [April 28, 2020, 2:31pm UTC](https://discourse.julialang.org/t/is-there-a-version-of-enumerate-in-the-reverse-order/38374/1 "2020-04-28T14:31:27Z")

</div>

I would like to enumerate an iterator with known length in reverse order. Something like:

```julia
julia> for t in enumerate(["a","b","c"], reverse=true); println(t); end
(3, "c")
(2, "b")
(1, "a")

```

Is there something builtin? For the moment, I build a vector and reverse it and iterate and change the index with “length - i” but it’s bad because I do not benefit from it being an iterator.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [April 28, 2020, 2:33pm UTC](https://discourse.julialang.org/t/is-there-a-version-of-enumerate-in-the-reverse-order/38374/2 "2020-04-28T14:33:10Z")

</div>

```julia
julia> for t in Iterators.reverse(enumerate(["a","b","c"])); println(t); end
(3, "c")
(2, "b")
(1, "a")

```

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [April 28, 2020, 2:36pm UTC](https://discourse.julialang.org/t/is-there-a-version-of-enumerate-in-the-reverse-order/38374/3 "2020-04-28T14:36:22Z")

</div>

love it ❤

---

<div class="post-metadata">

**Author:** ![fgerick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fgerick/32/13228_2.png) [@fgerick](https://discourse.julialang.org/u/fgerick)\
**Post date:** [October 16, 2023, 2:40pm UTC](https://discourse.julialang.org/t/is-there-a-version-of-enumerate-in-the-reverse-order/38374/4 "2023-10-16T14:40:49Z")

</div>

I just stumbled on this:

```julia
julia> reverse(enumerate([1,2,3]))
ERROR: MethodError: no method matching reverse(::Base.Iterators.Enumerate{Vector{Int64}})

Closest candidates are:
  reverse(::Tuple)
   @ Base tuple.jl:562
  reverse(::Pair{A, B}) where {A, B}
   @ Base pair.jl:53
  reverse(::NamedTuple)
   @ Base namedtuple.jl:324
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

julia> Iterators.reverse(enumerate([1,2,3]))
Base.Iterators.Reverse{Base.Iterators.Enumerate{Vector{Int64}}}(enumerate([1, 2, 3]))

```

Is there a reason/point-of-conflict for `Iterators.reverse` not being exported and I have to specify or could this be changed?
