Created
March 8, 2013 17:56
-
-
Save benoitjacquier/5118415 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; | |
namespace Monad | |
{ | |
public static class MyExtensions | |
{ | |
public static Func<T, V> Compose<T, U, V>(this Func<U, V> f, Func<T, U> g) | |
{ | |
return x => f(g(x)); | |
} | |
} | |
class MainClass | |
{ | |
static float AddOne( float input ) | |
{ | |
return input + 1; | |
} | |
static float MulByTwo( float input ) | |
{ | |
return input * 2; | |
} | |
public static void Main (string[] args) | |
{ | |
Func<float,float> addOne = AddOne; | |
Func<float,float> mulByTwo = MulByTwo; | |
//Cannot stepinto here | |
var r2 = addOne.Compose (mulByTwo) (3); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment