You can also memoize “expensive-calculation” …
https://clojuredocs.org/clojure.core/memoize
> On May 13, 2017, at 1:26 PM, Kevin Kleinfelter
> wrote:
>
> How would one convert the following procedural logic into functional/Clojure?
> x = expensive-calculation
> return (f1(x), f2(x), f
You are already doing exactly the right thing by having a temporary
variable.
To be precise a code fragment like:
(let [expensive-answer (some-fn x y z)
final-result { :k1 (f1 expensive-answer)
:k2 (f2 expensive-answer)
:k3 (f3 expensive-answer) }
How would one convert the following procedural logic into
functional/Clojure?
x = expensive-calculation
return (f1(x), f2(x), f3(x))
I'm sure I could force it by using a var to save the intermediate value,
but that's still procedural. It seems like the pattern of reusing an
expensive r