Skip to content

Instantly share code, notes, and snippets.

@hidori
Created June 23, 2014 05:07
Show Gist options
  • Save hidori/47e12142431579a79c5f to your computer and use it in GitHub Desktop.
Save hidori/47e12142431579a79c5f to your computer and use it in GitHub Desktop.
Scala っぽいやつ
public static class Scala
{
public static Func<T, V> Compose<T, U, V>(this Func<U, V> first, Func<T, U> second)
{
if (first == null) throw new ArgumentNullException("first");
if (second == null) throw new ArgumentNullException("second");
return t => first(second(t));
}
public static Func<T, V> AndThen<T, U, V>(this Func<T, U> first, Func<U, V> second)
{
if (first == null) throw new ArgumentNullException("first");
if (second == null) throw new ArgumentNullException("second");
return t => second(first(t));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment