anyone see any problems with my implementation of comp?
(defn my-comp
([] identity)
([f] f)
([f g] #(f (g %)))
([f g & fs]
(reduce
(fn [cf func]
(fn [& args] (cf (apply func args))))
(my-comp f g) fs)))
isn't it guaranteed that only the last function in the chain could possible get more than one arg?
I guess you don't need to account for that though
are you saying that the offical version guarantees that only the last fn can get multiple args?
This is probably the most meta thing i have ever written in my life, its giving me a headache 🙂
the spec for comp itself guarantees this
if you do (comp f g h) only h can have more than one arg
ah, I think thats what was bothering me about the difference between what i wrote and the official version. I was trying to understand how that version accounted for other functions in the chain handling more then one arg.