Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defn sum
(loop [total 0
coll coll]
(if (not-empty coll)
(recur (+ total (first coll)) (rest coll))
(defn average
(/ (sum coll) (count coll)))
(sum [1 2 4 5])
=> 12
(average [1 2 4 5])
=> 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment