All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.tonivade.purefun.Function3 Maven / Gradle / Ivy

/*
 * Copyright (c) 2018-2019, Antonio Gabriel Muñoz Conejo 
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.purefun;

@FunctionalInterface
public interface Function3 {

  R apply(A a, B b, C c);

  default Function1>> curried() {
    return a -> b -> c -> apply(a, b, c);
  }

  default Function1, R> tupled() {
    return tuple -> apply(tuple.get1(), tuple.get2(), tuple.get3());
  }

  default  Function3 andThen(Function1 after) {
    return (a, b, c) -> after.apply(apply(a, b, c));
  }

  default  Function1 compose(Function1 beforeT1, Function1 beforeT2, Function1 beforeT3) {
    return value -> apply(beforeT1.apply(value), beforeT2.apply(value), beforeT3.apply(value));
  }

  default Function3 memoized() {
    return (a, b, c) -> new MemoizedFunction<>(tupled()).apply(Tuple.of(a, b, c));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy