Skip to content

Instantly share code, notes, and snippets.

@Eckankar
Last active November 10, 2015 19:02
Show Gist options
  • Save Eckankar/77527285cafa5aff12ab to your computer and use it in GitHub Desktop.
Save Eckankar/77527285cafa5aff12ab to your computer and use it in GitHub Desktop.
local
fun avgSum' sum n [] = ([], sum div n)
| avgSum' sum n (x::xs) =
let val (rs, avg) = avgSum' (sum+x) (n+1) xs
in ((x-avg) :: rs, avg) end
in
val avgSum = #1 o avgSum' 0 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment