Skip to content

Instantly share code, notes, and snippets.

@ersiner
Last active December 11, 2015 09:48
Show Gist options
  • Save ersiner/4582160 to your computer and use it in GitHub Desktop.
Save ersiner/4582160 to your computer and use it in GitHub Desktop.
Not so dangerous functional Java
package functionaljavademo;
import com.google.common.base.Function;
import static com.google.common.collect.DiscreteDomains.integers;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Ranges.closed;
public class FunctionalJavaDemo
{
public static final Function<Integer, Integer> squareOf = new Function<Integer, Integer>()
{
public Integer apply ( Integer input ) { return input * input; }
};
public static void main ( String[] args )
{
System.out.println( transform( closed( 1, 25 ).asSet( integers() ), squareOf ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment