Skip to content

Instantly share code, notes, and snippets.

@terry3
Created January 19, 2017 07:29
Show Gist options
  • Save terry3/fff6921ba18dfbca9c470fd57610c651 to your computer and use it in GitHub Desktop.
Save terry3/fff6921ba18dfbca9c470fd57610c651 to your computer and use it in GitHub Desktop.
n comp implementation in clojure
(defn n-comp
[& fs]
(fn [& args]
(reduce #(%2 %1)
(apply (last fs) args)
(rest (reverse fs)))))
((n-comp inc inc inc inc inc ) 1) ; output 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment