SugarFN 1.0.0
dotnet add package SugarFN --version 1.0.0
NuGet\Install-Package SugarFN -Version 1.0.0
<PackageReference Include="SugarFN" Version="1.0.0" />
<PackageVersion Include="SugarFN" Version="1.0.0" />
<PackageReference Include="SugarFN" />
paket add SugarFN --version 1.0.0
#r "nuget: SugarFN, 1.0.0"
#:package SugarFN@1.0.0
#addin nuget:?package=SugarFN&version=1.0.0
#tool nuget:?package=SugarFN&version=1.0.0
SugarFN - Adds Additional Functional Features to C#'s FUNC datatype with extension methods. Combines imperative/procedural programming with the stateless programming. A few additional features are added to the List dataype.
Author: Raymond Nirnberger
Note: Most methods allow for at most 7 arguments
Example usage for AND:
Func<int, bool> num_is_even = ((n) ⇒ n % 2 == 0); Func<int, bool> num_is_even_and_greater_than_one_hundred = num_is_even.AND<int>((n) ⇒ n > 100);
(You'll need to keep the type signature, but in the type argument to "AND", you don't need the final return type. Only the arguments' types are required. Therefore, the "AND" call only requires an integer type argument. The final return type is snapshotted in the first call-site.
Example usage for "Coalesce":
Func<int, int> double_num_op = ((x) ⇒ x * 2);
Func<int, int> quadruple_num_op = ((x) ⇒ x * 4);
Func<int, int> octuple_num = ((x) ⇒ x * 8);
var application = double_num_op.Coalesce(quadruple_num_op).Coalesce(octuple_num); var result = application(10); (result is 640)...10 * 2, then 20 * 4, then 80 * 8. Essentially, coalesce takes the result of a function call and applies it to the next function.*
Example usage for "Dynamic Invoke": var even_nums = new List<int>() { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 }; Func<int, bool> is_evenly_divisible_by_four = ((x) ⇒ x % 4 == 0);
var results = is_evenly_divisible_by_four.DynamicInvoke<int, bool>(even_nums); (results will be false, true, flase, true, false, true, etc.).
Example usage for "IsFirst" and "IsLast". Note: only reference types are valid:
var lines = new List<Line>() { new Line(){x=0,y=0,width=1,height=1, id="line_1"}, new Line(){x=5,y=10,width=2, height=3, id="line_2"}, new Line(){x=10, y=20, width=3, height=6, id="line_3"}, new Line(){x=100, y=200, width=30, height=40, id="line_4"}, new Line(){x=500, y=600, width=100, height=64, id="line_5"} };
lines.ForEach((line) ⇒ { if(lines.IsFirst(line)) { Console.WriteLine("first item"); } else if(lines.IsLast(line)) { Console.WriteLine("last item"); } });
Example usage for "LeftSideObsolesce": Func<string, string, string> print_first_and_last_name = ((string first, string last) ⇒ first + " " + last);
var after_first_name_applied = print_first_and_last_name.LeftSideObsolesce("Frank"); var after_last_name_applied = after_first_name_applied.LeftSideObsolesce("Lernberger"); var name = after_last_name_applied(); Console.WriteLine(name); // will print out 'Frank Lernberger'
Example usage for "NOT": Func<int, bool> is_even = ((x) ⇒ x % 2 == 0); var is_odd = is_even.NOT<int>();
Console.WriteLine(is_even(3)); Console.WriteLine(is_odd(3));
Note, the original boolean return value is preserved, and is not required for passing as an argument while NOT'ing.
Example usage for "OR":
Func<string, bool> name_is_frank = ((s) ⇒ String.Equals(s, "Frank")); Func<string, bool> name_is_frank_or_john = name_is_frank.OR<string>((s) ⇒ String.Equals(s, "John"));
Console.WriteLine(name_is_frank("Frank")); Console.WriteLine(name_is_frank_or_john("John")); Console.WriteLine(name_is_frank_or_john("Frank")); Console.WriteLine(name_is_frank_or_john("Raymond"));
^^^ This will print out true, true, true, false
Example usage for "RightSideObsolesce":
Func<int, int, int> combine_nums = ((x, y) ⇒ x + y); Func<int, int> apply_y = combine_nums.RightSideObsolesce(10); Func<int> apply_x = apply_y.RightSideObsolesce(15);
int result = apply_x(); // prints out 25. Console.WriteLine(result);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 212 | 10/1/2025 |