fork download
  1. using System;
  2.  
  3. public static class Exts
  4. {
  5. public static Func<T1, R> then<T1,T2,R>(this Func<T1, T2> f, Func<T2, R> g)
  6. {
  7. return (x) => g(f(x));
  8. }
  9. }
  10.  
  11. public class Test
  12. {
  13.  
  14. public static void Main()
  15. {
  16. Func<int,int> f = (x) => (x * 2);
  17. Func<int,int> g = (y) => (y + 10);
  18. Func<int,int> h = f.then(g);
  19. System.Console.WriteLine(h(10));
  20. }
  21. }
Success #stdin #stdout 0.03s 33920KB
stdin
Standard input is empty
stdout
30