All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.effectiveosgi.lib.functional.Arrows Maven / Gradle / Ivy

The newest version!
package com.effectiveosgi.lib.functional;

import java.util.Map.Entry;
import java.util.function.Function;

/**
 * Functions for operating on pairs of values, inspired by Haskell Arrows
 */
public class Arrows {

	public static  Function, Entry> first(Function function) {
		return entry -> new MapEntry<>(function.apply(entry.getKey()), entry.getValue());
	}
	
	public static  Function, Entry> second(Function function) {
		return entry -> new MapEntry<>(entry.getKey(), function.apply(entry.getValue()));
	}
	
	public static  Function, Entry> combine(Function first, Function second) {
		return entry -> new MapEntry<>(first.apply(entry.getKey()), second.apply(entry.getValue()));
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy