-
-
Save theqp/bc8ca78ea961ef1dab6b85aa28a72952 to your computer and use it in GitHub Desktop.
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
import java.util.function.Function; | |
public class Pipe { | |
private Pipe() {} | |
public static <V, F1, R> R pipe(V v, Function<V, F1> f1, Function<F1, R> f2) { | |
return f2.apply(f1.apply(v)); | |
} | |
public static <V, F2, F3, R> R pipe( | |
V v, Function<V, F2> f1, Function<F2, F3> f2, Function<F3, R> f3) { | |
return f3.apply(f2.apply(f1.apply(v))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment