Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Functor<T> {
- private final T value;
- public Functor(T value) {
- this.value = value;
- }
- public <U> Functor<U> map(Function<T, U> mapperFunction) {
- return new Functor<>(mapperFunction.apply(value)); // Functor wrapping f(x)
- }
- }
Add Comment
Please, Sign In to add comment