Last active
August 29, 2015 14:06
-
-
Save s-amemiya/0054c67102f7780e07f7 to your computer and use it in GitHub Desktop.
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 characters
| using System; | |
| class Program | |
| { | |
| static void Main() | |
| { | |
| Func<int, Func<int, int>> curriedSum = lhs => rhs => lhs + rhs; // currying | |
| Console.WriteLine(curriedSum(1)(2)); // 3 | |
| Console.WriteLine(curriedSum(4)(5)); // 9 | |
| var onePlus = curriedSum(1); | |
| Console.WriteLine(onePlus(1)); // 2 | |
| Console.WriteLine(onePlus(211)); // 212 | |
| var twoPlus = curriedSum(2); | |
| Console.WriteLine(twoPlus(1)); // 3 | |
| Console.WriteLine(twoPlus(211)); // 213 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment