Foldl1 fix for nearest_mean