code-reviews

2017-06-18T23:26:06.376804Z

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)))

2017-06-18T23:28:06.383695Z

isn't it guaranteed that only the last function in the chain could possible get more than one arg?

2017-06-18T23:28:45.385887Z

I guess you don't need to account for that though

2017-06-18T23:29:31.388556Z

are you saying that the offical version guarantees that only the last fn can get multiple args?

2017-06-18T23:30:14.391117Z

This is probably the most meta thing i have ever written in my life, its giving me a headache 🙂

2017-06-18T23:30:49.393076Z

the spec for comp itself guarantees this

2017-06-18T23:31:06.394143Z

if you do (comp f g h) only h can have more than one arg

2017-06-18T23:32:59.400793Z

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.