class Functions {

  public static <R, V> Function0<V> compose(final Function0<R> first,
      final Function1<? super R, ? extends V> second) {
    if (null == first) {
      throw new NullPointerException();
    }
    if (null == second) {
      throw new NullPointerException();
    }
    return new Function0<V>() {
      @Override
      public V apply() {
        return second.apply(first.apply());
      }
    };
  }

}