code: public static <K,V> Function<K,V> map2fun(final Map<K,V> map) {
  	return new Function<K,V>() {
  	    public V f(K key) {
  		V value = map.get(key);
  		if(value == null) {
  		    throw new Error("No value for " + key);
  		}
  		return value;
  	    }
  	};
      }
docs: Construct a <code>Function</code> based on a map.  The
  resulting function will throw an exception if invoked on an
  element that is unassigned in <code>map</code>.