Skip to content

Instantly share code, notes, and snippets.

@fadelakin
Created October 19, 2013 17:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fadelakin/7058608 to your computer and use it in GitHub Desktop.
Save fadelakin/7058608 to your computer and use it in GitHub Desktop.
A function that calculates the average of some numbers in Clojure
(defn average
[numbers]
(/ (apply + numbers) (count numbers)))
@bfontaine
Copy link

You might want to use reduce instead of apply. The former is a lot faster than the latter if you have a lot of numbers.

@Bost
Copy link

Bost commented May 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment