Skip to content

Instantly share code, notes, and snippets.

@msfroh
Created July 30, 2012 21:46
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 msfroh/3210574 to your computer and use it in GitHub Desktop.
Save msfroh/3210574 to your computer and use it in GitHub Desktop.
Function composition
public abstract class Function1<R, T1> {
/* ... previous method definitions ... */
public <R2> Function1<R2, T1> compose(final Function1<R2, R> f) {
return new Function1<R2, T1>() {
@Override
public R2 evaluate(final Function1<R2, T1> self, final T1 i1) {
return f.evaluate(f, Function1.this.evaluate(Function1.this, i1));
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment