Skip to content

Instantly share code, notes, and snippets.

@bennage
Created September 12, 2010 05:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennage/575857 to your computer and use it in GitHub Desktop.
Save bennage/575857 to your computer and use it in GitHub Desktop.
reduce function, functional version
// functional version - recursion instead of a loop
static int ReduceF(Func<int, int, int> reducer, IEnumerable<int> values, int seed)
{
return values.Any()
? ReduceF(reducer, values.Skip(1), reducer(seed, values.First()))
: seed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment