private static <K, V> Function<K, V> cachingFunction(Function<K, V> f) {
    Map<K, V> cache = new HashMap<>();
    return k -> cache.computeIfAbsent(k, f);
  }
private static <K, V> Function<K, V> cachingFunction(Function<K, V> f)