Created
July 30, 2012 21:46
-
-
Save msfroh/3210574 to your computer and use it in GitHub Desktop.
Function composition
This file contains 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
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