<p>memoize.</p>

@param function a {@link java.util.function.Supplier} object.
@param <T> a T object.
@return a {@link java.util.function.Supplier} object.
493696
public static <T> Supplier<T> memoize(final Supplier<T> function) {
    return new Memoizer<T, T>().doMemoize(function);
  }
108523
public static <T, R> Function1<T, R> memoizeFunction(final Function<T, R> fn, final Cacheable<R> cache) {
        LazyImmutable<R> nullR = LazyImmutable.def();
        return t -> t==null? nullR.computeIfAbsent(()->fn.apply(null)) : (R)cache.soften()
                         .computeIfAbsent(t, (Function) fn);
    }
75059
public <R> AnimaQuery<T> order(TypeFunction<T, R> function, OrderBy orderBy) {
        String columnName = AnimaUtils.getLambdaColumnName(function);
        return order(columnName, orderBy);
    }
1031869
def memoize(func, cache, num_args):
    

    @wraps(func)
    def wrapper(*args):
        mem_args = args[:num_args]
        if mem_args in cache:
            return cache[mem_args]
        result = func(*args)
        cache[mem_args] = result
        return result

    return wrapper
61742
public static <T1, T2, T3, T4, R> Function4<T1, T2, T3, T4, R> memoizeQuadFunction(final Function4<T1, T2, T3, T4, R> fn) {
      Function1<Tuple4<T1, T2, T3, T4>, R> memoise2 = memoizeFunction((final Tuple4<T1, T2, T3, T4> quad) -> fn.apply(quad._1(), quad._2(), quad._3(), quad._4()));
        return (t1, t2, t3, t4) -> memoise2.apply(tuple(t1, t2, t3, t4));
    }
622623
public static <T> Supplier<T> memoized(Supplier<T> actual) {
        return new Supplier<T>() {
            Supplier<T> delegate = this::initialize;
            boolean initialized;

            public T get() {
                return delegate.get();
            }

            private synchronized T initialize() {
                if (!initialized) {
                    T value = actual.get();
                    delegate = () -> value;
                    initialized = true;
                }
                return delegate.get();
            }
        };
    }
82355
def memoized(func):
    
    cache = {}
    @wraps(func)
    def memoized_function(*args):
        """The decorated function.
        """
        try:
            return cache[args]
        except KeyError:
            value = func(*args)
            try:
                cache[args] = value
            except MemoryError:
                cache.clear()
                gc.collect()
            return value
    return memoized_function
1333919
def memoize(func):
  
  class Memoizer(dict):
    def __missing__(self, args):
      val = func(*args)
      self[args] = val
      return val
  memory = Memoizer()
  @wraps(func)
  def wrapper(*args):
    return memory[args]
  return wrapper
464954
public static <T, U> Collector<T, ?, Seq<T>> maxAllBy(Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
        class Accumulator {
            List<T> t = new ArrayList<>();
            U u;
            void set(T t, U u) {
                this.t.clear();
                this.t.add(t);
                this.u = u;
            }
        }

        return Collector.of(
            () -> new Accumulator(),
            (a, t) -> {
                U u = function.apply(t);
                if (a.u == null) {
                    a.set(t, u);
                }
                else {
                    int compare = comparator.compare(a.u, u);

                    if (compare < 0)
                        a.set(t, u);
                    else if (compare == 0)
                        a.t.add(t);
                }
            },
            (a1, a2) -> {
                if (a1.u == null)
                    return a2;
                if (a2.u == null)
                    return a1;

                int compare = comparator.compare(a1.u, a2.u);

                if (compare < 0)
                    return a1;
                else if (compare > 0)
                    return a2;

                a1.t.addAll(a2.t);
                return a1;
            },
            a -> Seq.seq(a.t)
        );
    }
685355
public static <E> Supplier<E> before(final int count, final Supplier<E> function) {
        class BeforeFunction implements Supplier<E> {
            private final int count;
            private final Supplier<E> localFunction;
            private int index;
            private E result;

            BeforeFunction(final int count, final Supplier<E> function) {
                this.count = count;
                this.localFunction = function;
            }
            public E get() {
                if (++index <= count) {
                    result = localFunction.get();
                }
                return result;
            }
        }
        return new BeforeFunction(count, function);
    }
411024
@SneakyThrows
    public static <R> Supplier<R> doIf(final boolean condition, final Supplier<R> trueFunction,
                                       final Supplier<R> falseFunction) {
        return () -> {
            try {
                if (condition) {
                    return trueFunction.get();
                }
                return falseFunction.get();
            } catch (final Throwable e) {
                LOGGER.warn(e.getMessage(), e);
                return falseFunction.get();
            }
        };
    }
121424
public static <T1,T2,T3> Function<T1,T3> comp(final Function<T2,T3> func1, final Function<T1,T2> func2) {
	return new Function<T1,T3>() {
	    public T3 f(T1 x) {
		return func1.f(func2.f(x));
	    }
	};
    }
173225
public static <A, B> Mapper<A, B> fromFunction(final Function<A, B> function) {
    return new Mapper<A, B>() {
      @Override
      public B map(A item) {
        return function.apply(item);
      }
    };
  }
493859
def memoize(f):
    
    cache = {}

    @wraps(f)
    def inner(arg):
        if arg not in cache:
            cache[arg] = f(arg)
        return cache[arg]
    return inner
1359572
public static <T, F> Function<F, T> bind(final Function<F, T> function) {
        return new Function<F, T>() {
            @Override
            public T apply(F arg) {
                return function.apply(arg);
            }
        };
    }
1253933
function memoize(fn) {
  const dataProp = '__data__.string.__data__',
    memFn = _.memoize.apply(_, _.slice(arguments)),
    report = _.throttle(reportMemoryLeak, minute),
    controlFn = function () {
      const result = memFn.apply(null, _.slice(arguments));

      if (_.size(_.get(memFn, `cache.${dataProp}`)) >= memoryLeakThreshold) {
        report(fn, _.get(memFn, `cache.${dataProp}`));
      }

      return result;
    };

  Object.defineProperty(controlFn, 'cache', defineWritable({
    get() { return memFn.cache; },
    set(value) { memFn.cache = value; }
  }));

  return controlFn;
}
587760
public static <T, R> Consumer<T> consumer(Function<T, R> function) {
        dbc.precondition(function != null, "cannot adapt a null function");
        return function::apply;
    }