Skip to content

Instantly share code, notes, and snippets.

@goofballLogic
Created December 16, 2019 19:29
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 goofballLogic/75364969767246e35e662d89dcdb5f7f to your computer and use it in GitHub Desktop.
Save goofballLogic/75364969767246e35e662d89dcdb5f7f to your computer and use it in GitHub Desktop.
long[] Consume(long[] source, long quantity)
{
var acc = 0L;
bool Accumulate(long x)
{
if (acc > quantity) return false;
acc += x;
return true;
}
return source.SkipWhile(Accumulate).ToArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment