# Precompute some values of a function

**URL:** <https://discourse.julialang.org/t/precompute-some-values-of-a-function/82079>\
**Category:** Performance\
**Tags:** question, memoize\
**Created:** [June 1, 2022, 7:28pm UTC](https://discourse.julialang.org/t/precompute-some-values-of-a-function/82079 "2022-06-01T19:28:09Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 1, 2022, 8:43pm UTC](https://discourse.julialang.org/t/precompute-some-values-of-a-function/82079/7 "2022-06-01T20:43:23Z")

</div>

Or a functor, see one example here:

> [@When and How to use Types](https://discourse.julialang.org/t/when-and-how-to-use-types/56659/5):
>
> Maybe [Memoize.jl](https://github.com/JuliaCollections/Memoize.jl) is useful to you. Anyway, I would probably use a more pedestrian approach, by computing keeping r as a parameter and adding the constant terms, precomputed, to a data structure to be sent to the function as a parameter as well. But of course how practical is that depends on your actual problem. One alternative which I find cool, although I am not sure if that will fit your needs either, is to use a functor, something like this: The struct is parametric on the constants, and t…

---

_[View the full topic](https://discourse.julialang.org/t/precompute-some-values-of-a-function/82079)._
