Skip to content

Commit

Permalink
Simplify looping condition in Sequence operator
Browse files Browse the repository at this point in the history
  • Loading branch information
leandromoh authored and atifaziz committed Feb 25, 2018
1 parent 66d3458 commit f09050d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions MoreLinq/Sequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ public static IEnumerable<int> Sequence(int start, int stop)

public static IEnumerable<int> Sequence(int start, int stop, int step)
{
var initial = start;
long current = start;

while (step >= 0 ? stop >= current && initial <= current
: stop <= current && initial >= current)
while (step >= 0 ? stop >= current
: stop <= current)
{
yield return (int)current;
current = current + step;
Expand Down

0 comments on commit f09050d

Please sign in to comment.