I would like to define a list of functions to use within juxt, however I am having trouble implementing it.
Heres an example of what I want:
(defn sin [n] (Math/sin n))
(defn cos [n] (Math/cos n))
((juxt sin cos) 4)
>> [-0.7568024953079282 -0.6536436208636119]
Now instead of saying ((juxt sin cos) 4) I would prefer to say ((juxt trig) 4) where
(def trig [sin cos]). I have attempted ((apply juxt trig) 4) and a few other things but nothing seems to stick. Thanks!
apply seems to work fine:
user=> ((juxt sin cos) 4)
[-0.7568024953079282 -0.6536436208636119]
user=> ((apply juxt trig) 4)
[-0.7568024953079282 -0.6536436208636119]
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