Skip to content

Instantly share code, notes, and snippets.

@amoilanen
Created September 19, 2011 20:55
Show Gist options
  • Save amoilanen/1227586 to your computer and use it in GitHub Desktop.
Save amoilanen/1227586 to your computer and use it in GitHub Desktop.
Demo of "Functional Java" library http://functionaljava.org
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