Name: Anonymous 2015-07-08 17:53
Rules:
✡ must compute arithmetic average of a list
✡ only one pass is allowed
✡ constant memory
✡ must compute arithmetic average of a list
✡ only one pass is allowed
✡ constant memory
avg xs = worker 1 0 xs
where worker _ acc [] = acc
worker n acc (x:xs) = worker (n + 1) (acc * (1 - 1 / n) + x / n) xs