So if I understand this correctly, when I write:
(defn foo [x] (+ (* (- x 3) 2) (- x 3)))
foo gets bound to:
(fn [x] (+ (* (- x 3) 2) (- x 3)))
How do I access the function from foo? My intention is to change something in the function and return a new function.
If you want to use the function value stored in the Var foo, just write foo, for example:
(def foo2 (comp - foo))
(foo 4) ;;=> 3
(foo2 4) ;;=> -3
There is no special deref notation for Vars: just use their name and they get resolved to their bound value. Functions are not something you change, but you can build functions out of other ones, like above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With