# Seven Lines of Julia (examples sought)

**URL:** <https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416>\
**Category:** General Usage\
**Created:** [November 19, 2020, 7:37am UTC](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416 "2020-11-19T07:37:29Z")\
**Posts on this page:** 1\
**Showing post:** 81

<div class="post-metadata">

**Author:** ![FedericoStra](https://avatars.discourse-cdn.com/v4/letter/f/76d3ee/32.png) [@FedericoStra](https://discourse.julialang.org/u/FedericoStra)\
**Post date:** [April 9, 2021, 2:56pm UTC](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416/81 "2021-04-09T14:56:48Z")

</div>

Your code still wastes memory to create the useless vector `fill(F, n)`. Also, it doesn’t support the case `n=0`. Just do this instead

```julia
Fn(x, n) = foldl((y,_) -> F(y), 1:n; init=x)

```

_Edit_: of course one can use a `StaticArrays.SVector{3}` to sqeeze out the last bit of performance.

---

_[View the full topic](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416)._
