Skip to content

Instantly share code, notes, and snippets.

@benoitjacquier
Created March 8, 2013 17:56
Show Gist options
  • Save benoitjacquier/5118415 to your computer and use it in GitHub Desktop.
Save benoitjacquier/5118415 to your computer and use it in GitHub Desktop.
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