Learn C# Programming by Marius Bancila Raffaele Rialdi and Ankit Sharma
Author:Marius Bancila, Raffaele Rialdi, and Ankit Sharma
Language: eng
Format: epub
Publisher: Packt Publishing Ptv Ltd
Published: 2020-04-28T00:00:00+00:00
These, when put in code, would look as follows:
var f1 = Curry<int, double, string, string>(AsString);
var f2 = f1(42);
var f3 = f2(43.5);
string result = f3("44");
The generic Curry() function seen here is similar to the Apply() function from the previous section. However, instead of returning a function with N-1 arguments, it returns a function with a single argument:
Func<T1, Func<T2, Func<T3, TResult>>>
Curry<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> f)
{
return a => b => c => f(a, b, c);
}
This function can be used to curry functions with exactly three parameters. Should you need to do that with functions that have another number of parameters, then you need appropriate overloads for it (just as in the case of Apply()).
You should note that you do not necessarily need to decompose the AsString() function three different times, as seen earlier with f1, f2, and f3. You can skip intermediate functions and achieve the same result by invoking the function appropriately, as shown in the following code:
var f = Curry<int, double, string, string>(AsString);
string result = f(42)(43.5)("44");
Another important concept in function programming is closures. We'll learn about closures in the next section.
Download
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.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12568)
Hello! Python by Anthony Briggs(9913)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9795)
The Mikado Method by Ola Ellnestam Daniel Brolund(9777)
Dependency Injection in .NET by Mark Seemann(9337)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8295)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7054)
Microservices with Go by Alexander Shuiskov(6817)
Practical Design Patterns for Java Developers by Miroslav Wengner(6734)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6675)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Angular Projects - Third Edition by Aristeidis Bampakos(6080)
The Art of Crafting User Stories by The Art of Crafting User Stories(5607)
NetSuite for Consultants - Second Edition by Peter Ries(5547)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5347)
Kotlin in Action by Dmitry Jemerov(5062)
