Introducing Functional Programming Using C# by Vaskaran Sarcar

Introducing Functional Programming Using C# by Vaskaran Sarcar

Author:Vaskaran Sarcar
Language: eng
Format: epub, pdf
ISBN: 9781484296974
Publisher: Apress


// Get a coupon discount

int couponDiscount = seasonalDiscount < 10

? 5 : new Random().Next(1, 3);

// Calculate cost after coupon discount

WriteLine($"Coupon discount={couponDiscount}%");

var afterCouponDiscount = afterSeasonalDiscount(couponDiscount);

return afterCouponDiscount;

}

}

namespace CustomLibrary

{

public static class CurryExtensions

{

public static Func<double, Func<int, Func<int,

double>>> NonGenericCurry(

this Func<double, int, int, double> f)

{

return x => y => z => f(x, y, z);

}

public static Func<T1, Func<T2, Func<T3, TResult>>>

GenericCurry<T1, T2, T3, TResult>

(this Func<T1, T2, T3, TResult> f)

{

return (T1 x) => (T2 y) => (T3 z) => f(x, y, z);

}

}

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.