code: public static DoubleUnaryOperator clamp(
          final DoubleUnaryOperator function,
          final double min, final double max)
      {
          return x -> Math.max(min, Math.min(max, function.applyAsDouble(x)));
      }
docs: Returns a {@link DoubleUnaryOperator} that clamps the results from the
  given function to the interval [min,max]
  
  @param function The function to clamp
  @param min The minimum value
  @param max The maximum value
  @return The {@link DoubleUnaryOperator}