Created
December 2, 2011 16:16
-
-
Save ejackson/1423801 to your computer and use it in GitHub Desktop.
A quick moving average
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn sma [n s] | |
{:pre [(pos? n)]} | |
(concat | |
(repeat (dec n) nil) | |
(map #(/ (reduce + %) n) (partition n 1 s)))) |
ihodes
commented
Dec 2, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment