Last active
December 11, 2015 09:48
-
-
Save ersiner/4582160 to your computer and use it in GitHub Desktop.
Not so dangerous functional Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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