# More idiomatic way of phrasing \`reduce(\\circ, repeated(f, x))(y)\`?

**URL:** <https://discourse.julialang.org/t/more-idiomatic-way-of-phrasing-reduce-circ-repeated-f-x-y/138647>\
**Category:** Performance\
**Tags:** performance, functional\
**Created:** [August 6, 2026, 3:01pm UTC](https://discourse.julialang.org/t/more-idiomatic-way-of-phrasing-reduce-circ-repeated-f-x-y/138647 "2026-08-06T15:01:49Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [August 6, 2026, 3:13pm UTC](https://discourse.julialang.org/t/more-idiomatic-way-of-phrasing-reduce-circ-repeated-f-x-y/138647/2 "2026-08-06T15:13:32Z")

</div>

of course the magic related section is better at searching than the search bar or the related posts that pop up when composing a thread.

[from here](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416/81) (mentioned [here](https://discourse.julialang.org/t/recursively-applied-1d-function/67602/4))

```julia-auto
julia> f(a) = foldl((x,_) -> exp(x), repeated(nothing, 1000); init=a)
f (generic function with 1 method)

julia> @benchmark f(10.)
BenchmarkTools.Trial: 10000 samples with 999 evaluations per sample.
 Range (min … max): 8.146 ns … 25.388 ns ┊ GC (min … max): 0.00% … 0.00%
 Time (median): 8.871 ns ┊ GC (median): 0.00%
 Time (mean ± σ): 8.995 ns ± 1.472 ns ┊ GC (mean ± σ): 0.00% ± 0.00%

  █▄ ▅█▂ ▃ ▁
  ██▇▆▇█████▇▇▆▆▆▆▆▆▆▆▆▆▅▆▆▆▅▆▆▅▆▇▅▇▇▆▆▇▆▇▇▇▅▆▇▆▇▆▇▇▇▆▇▇▇▇▆▆ █
  8.15 ns Histogram: log(frequency) by time 15.2 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

```

---

_[View the full topic](https://discourse.julialang.org/t/more-idiomatic-way-of-phrasing-reduce-circ-repeated-f-x-y/138647)._
