Skip to content

Instantly share code, notes, and snippets.

@CarstenKoenig
Created October 13, 2014 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarstenKoenig/26e46150c6458609d756 to your computer and use it in GitHub Desktop.
Save CarstenKoenig/26e46150c6458609d756 to your computer and use it in GitHub Desktop.
extension method on Func
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