Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Recipes.LINQ.R0102
- {
- public class FunctionalMethods
- {
- public static void Main()
- {
- // Functional method f(x) and g(x):
- Func<int, int> f = x => x + 1;
- Func<int, int> g = x => x + 2;
- // Compound functional method f(g(x)):
- Func<Func<int, int>, Func<int, int>, int, int> fog = (f1, g1, x) => f1.Invoke(g1.Invoke(x));
- Console.WriteLine();
- // Computing f(x) with x = 2:
- Console.WriteLine("f(2) = {0}", f(2));
- Console.WriteLine("g(3) = {0}", g(3));
- Console.WriteLine("f(g(5) = {0}", fog(f, g, 5));
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement