Created
October 13, 2014 04:51
-
-
Save CarstenKoenig/26e46150c6458609d756 to your computer and use it in GitHub Desktop.
extension method on Func
This file contains 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
public static class FuncTest | |
{ | |
public static int TestMe() | |
{ | |
Func<int, int> f = x => x + 5; | |
var val = f.Fmap(x => x*2)(3); | |
Console.WriteLine(val); | |
return val; | |
} | |
public static Func<A, C> Fmap<A, B, C>(this Func<A, B> f, Func<B, C> g) | |
{ | |
return x => g(f(x)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment