https://github.com/brunozell/enumerizer
Provides a simple range-like syntax for integer iterations through clever hacks.
https://github.com/brunozell/enumerizer
csharp netcore range
Last synced: over 1 year ago
JSON representation
Provides a simple range-like syntax for integer iterations through clever hacks.
- Host: GitHub
- URL: https://github.com/brunozell/enumerizer
- Owner: BrunoZell
- License: mit
- Created: 2019-08-21T05:37:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-03T18:28:19.000Z (almost 7 years ago)
- Last Synced: 2025-01-29T03:52:46.806Z (over 1 year ago)
- Topics: csharp, netcore, range
- Language: C#
- Homepage:
- Size: 14.6 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Enumerizer
A mini utility that provides a declarative way to iterate integers:
```csharp
// Import Enumerizer in each file you want to use it
using static Enumerizer;
// 0 1 2 3 4 5 6 7 8 9
foreach (int i in 0 <= i < 10)
Console.Write(i + " ");
// 10 9 8 7 6 5 4 3 2 1 0
foreach (int i in 10 >= i >= 0)
Console.Write(i + " ");
// 10 8 6 4 2 0
foreach (int i in 10 >= i >= 0 | 2)
Console.Write(i + " ");
// -13 -10 -7 -4 -1 2 5 8
foreach (int i in -14 < i <= 10 | 3)
Console.Write(i + " ");
```
A usage with Linq is also possible:
```csharp
using System.Linq;
using static Enumerizer;
// [ -3, -2, -1, 0, 1, 2, 3 ]
int[] it = (-3 <= i <= 3).ToArray();
```