name | PartiallyApplied |
nuget |
https://www.nuget.org/packages/PartiallyApplied/ |
link | https://github.com/JasonBock/PartiallyApplied |
author | Andrei Ignat |
This will generate curry for your functions
The code that you start with is
public class Accounting { public static float Discount( float discount,float price) { var val= price * (1- discount); return val; } }
The code that you will use is
var disc10Percent = Partially.Apply(Accounting.Discount,1/10f); Console.WriteLine(disc10Percent(disc10Percent(100)));
The code that is generated is
public static partial class Partially { public static Func<float,float> Apply(Func<float,float,float> method,float discount) => new((price) => method(discount,price)); }
Example Code: https://github.com/ignatandrei/RSCG_Examples/tree/main/PartiallyFunction
Leave a Reply