Last active
March 9, 2020 12:25
-
-
Save ZacharyPatten/c6e46acd39d3e1d1d19e8da9a482d303 to your computer and use it in GitHub Desktop.
Revisions
-
ZacharyPatten revised this gist
Feb 5, 2020 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ using System; using static FOR; public class Program -
ZacharyPatten revised this gist
Feb 5, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ For when you are too lazy to type out an entire for loop. using System; using static FOR; public class Program -
ZacharyPatten revised this gist
Feb 5, 2020 . No changes.There are no files selected for viewing
-
ZacharyPatten revised this gist
Feb 5, 2020 . 1 changed file with 22 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ For when you are too lazy to type out an entire for loop... using System; using static FOR; public class Program { public static int Main() => For (1..4) > Console.WriteLine; } public struct FOR { public static FOR For(Range range) => new FOR(range); public Range Value; public FOR(Range range) => Value = range; public static int operator >(FOR @for, Action<int> action) { for (int i = @for.Value.Start.Value; i < @for.Value.End.Value; i++) action(i); return default; } public static int operator <(FOR @for, Action<int> action) => throw new NotImplementedException(); } -
ZacharyPatten revised this gist
Nov 27, 2019 . 1 changed file with 29 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,22 +2,33 @@ namespace Example { class Program { static void Main() { For (10..5) ( Console.WriteLine ); For (5..10, Console.WriteLine); } public static Action<Action<int>> For(Range range) => x => { int a = range.Start.Value; int b = range.End.Value; if (a > b) for (int i = a; i >= b; i--) x(i); else for (int i = a; i <= b; i++) x(i); }; public static void For(Range range, Action<int> action) { int a = range.Start.Value; int b = range.End.Value; if (a > b) for (int i = a; i >= b; i--) action(i); else for (int i = a; i <= b; i++) action(i); } } } -
ZacharyPatten revised this gist
Nov 27, 2019 . No changes.There are no files selected for viewing
-
ZacharyPatten revised this gist
Nov 27, 2019 . 1 changed file with 16 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,19 +2,22 @@ namespace Example { class Program { static void Main() { For (10, To: 5) ( Console.WriteLine ); } public static Action<Action<int>> For(int from, int? To = null) => x => { if (!To.HasValue) throw new ArgumentNullException(nameof(To)); else if (from > To) for (int i = from; i >= To; i--) x(i); else for (int i = from; i <= To; i++) x(i); }; } } -
ZacharyPatten revised this gist
Nov 27, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public static Action<Action<int>> For(int from, int? To = null) => x => { if (!To.HasValue) throw new ArgumentNullException(nameof(To)); else if (from > To) for (int i = from; i >= To; i--) x(i); else for (int i = from; i <= To; i++) x(i); }; } -
ZacharyPatten created this gist
Nov 27, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ using System; namespace Example { static void Main() { For (10, To: 5) ( Console.WriteLine ); } public static Action<Action<int>> For(int from, int? To = null) => x => { if (!To.HasValue) throw new ArgumentNullException(nameof(To)); else if (from > to) for (int i = from; i >= to; i--) x(i); else for (int i = from; i <= to; i++) x(i); }; }