# Iterator powers?

**URL:** <https://discourse.julialang.org/t/iterator-powers/83060>\
**Category:** General Usage\
**Created:** [June 20, 2022, 12:06pm UTC](https://discourse.julialang.org/t/iterator-powers/83060 "2022-06-20T12:06:40Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Post date:** [June 20, 2022, 12:50pm UTC](https://discourse.julialang.org/t/iterator-powers/83060/4 "2022-06-20T12:50:16Z")

</div>

Interesting question. I doubt this is the best answer, but:

```julia
julia> A × B = (Iterators.Flatten((a, b)) for a in A for b in B)
× (generic function with 1 method)

julia> reduce(×, 0:4 for _ in 1:3)
Base.Iterators.Flatten{Base.Generator{Base.Iterators.Flatten{Base.Generator{UnitRange{Int64}, var"#52#53"{UnitRange{Int64}}}}, var"#52#53"{UnitRange{Int64}}}}(Base.Generator{Base.Iterators.Flatten{Base.Generator{UnitRange{Int64}, var"#52#53"{UnitRange{Int64}}}}, var"#52#53"{UnitRange{Int64}}}(var"#52#53"{UnitRange{Int64}}(0:4), Base.Iterators.Flatten{Base.Generator{UnitRange{Int64}, var"#52#53"{UnitRange{Int64}}}}(Base.Generator{UnitRange{Int64}, var"#52#53"{UnitRange{Int64}}}(var"#52#53"{UnitRange{Int64}}(0:4), 0:4))))

julia> collect(collect(i) for i in ans)
125-element Vector{Vector{Int64}}:
 [0, 0, 0]
 [0, 0, 1]
 [0, 0, 2]
# ...

```

where the `×` operator defined above might be the rare legitimate use case for defining infix operators as discussed in this other thread from today: [Does anybody use the syntax `a \<operator\> b = ...` to define new methods for operators? - #8 by dylanxyz](https://discourse.julialang.org/t/does-anybody-use-the-syntax-a-operator-b-to-define-new-methods-for-operators/83034/8)

This could be a useful feature in Combinatorics.jl.

---

_[View the full topic](https://discourse.julialang.org/t/iterator-powers/83060)._
