Skip to content

Instantly share code, notes, and snippets.

@abhijith
Created March 11, 2014 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhijith/9483463 to your computer and use it in GitHub Desktop.
Save abhijith/9483463 to your computer and use it in GitHub Desktop.
;; Without using partial
(defn sums-to-n? [n]
(fn [coll]
(= n (reduce + coll))))
(def f (sums-to-n? 10))
(f [1 2 3]) ; false
(f [1 2 3 4]) ; true
;; Using ```partial```
(defn sums-to-n?
[n coll]
(= n (reduce + coll)))
(def f (partial sums-to-n? 10))
(f [1 2 3]) ; false
(f [1 2 3 4]) ; true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment