Skip to content

Instantly share code, notes, and snippets.

@bennage
Created September 12, 2010 04:54
Show Gist options
  • Save bennage/575854 to your computer and use it in GitHub Desktop.
Save bennage/575854 to your computer and use it in GitHub Desktop.
reduce function, imperative version
// imperative version - uses a loop
static int Reduce(Func<int, int, int> reducer, IEnumerable<int> values)
{
int accum = 0;
foreach (var i in values)
{
accum = reducer(accum, i);
}
return accum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment