Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active April 30, 2017 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/cc645cc501ca465935343cbbaf9e8da7 to your computer and use it in GitHub Desktop.
Save deque-blog/cc645cc501ca465935343cbbaf9e8da7 to your computer and use it in GitHub Desktop.
template<typename Container>
int sum_recur(Container const& coll)
{
int total = 0;
for (int val: coll)
total += val;
return total;
}
template<typename Container>
int average(Container const& coll)
{
return sum_recur(coll) / coll.size();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment