code-reviews

dancrumb 2016-04-02T13:55:06.000018Z

morning folks

dancrumb 2016-04-02T13:55:16.000019Z

I’m working through exercise 2 on this site: http://www.braveclojure.com/functional-programming/#Exercises

dancrumb 2016-04-02T13:55:27.000020Z

I have

(defn my-comp
  "Exercise 2: Implementing comp"
  [f & fs]
  (if (nil? fs)
    (fn [& args] (apply f args))
    (fn [& args] (f (apply (apply my-comp fs) args)))
  )
)

dancrumb 2016-04-02T13:55:36.000022Z

it works

dancrumb 2016-04-02T13:56:00.000023Z

but the (f (apply (apply my-comp fs) args)) form seems clunky

dancrumb 2016-04-02T13:56:04.000024Z

any thoughts?

2016-04-02T18:50:27.000025Z

if you make the base case for two functions instead of one you can use reduce

dancrumb 2016-04-02T19:12:06.000026Z

Nice