Created
September 19, 2011 20:55
-
-
Save amoilanen/1227586 to your computer and use it in GitHub Desktop.
Demo of "Functional Java" library http://functionaljava.org
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 functional.examples; | |
import static fj.data.Array.array; | |
import org.junit.Assert; | |
import org.junit.Test; | |
import fj.F; | |
import fj.data.Array; | |
/** | |
* Simple demo of using the "functional Java" library. | |
* http://functionaljava.org/ | |
*/ | |
public class FunctionalJavaExample { | |
@Test | |
public void testArrayTransformation() { | |
Assert.assertArrayEquals(new Integer[] {1, 2, 3}, | |
Array.<String, Integer>map().f(new F<String, Integer>() { | |
@Override | |
public Integer f(String arg) { | |
return arg.length(); | |
} | |
}).f(array("a", "ab", "abc")).array(Integer[].class)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment