Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created February 4, 2012 23:11
Show Gist options
  • Select an option

  • Save anaisbetts/1741011 to your computer and use it in GitHub Desktop.

Select an option

Save anaisbetts/1741011 to your computer and use it in GitHub Desktop.
public static IEnumerable<TAcc> Scan<T, TAcc>(this IEnumerable<T> This, TAcc initialValue, Func<TAcc, T, TAcc> accFunc)
{
TAcc acc = initialValue;
foreach (var x in This)
{
acc = accFunc(acc, x);
yield return acc;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment