jcurry


tasty functional goodness

With jcurry, methods can become curried functions. You mark a method with the annotation @AsFunction, and then you can use it in any collections method that takes a function*: ``` @AsFunction private static int increment(int x) { return ++x; }

@Test
public void testTransformList()
{
    assertEquals(asList(2, 3), transform(asList(1, 2), increment));
}

You can also partially apply any method with more than one parameter: @AsFunction private static String concat(String prefix, int suffix) { return prefix + suffix; }

@Test
public void testTransformListWithPartialApplication()
{
    assertEquals(asList("Fred1", "Fred2"), transform(asList(1, 2), concat.apply("Fred")));
}

``` jcurry works with any instance method, static methods with one or more parameter, and even constructors and fields. Try it out!

jcurry also includes some utilities for functional-style programming in Java.

* A Google Guava function, that is. Come Java 8, it'll be all about first-class functions...


... jcurry only works with Eclipse

... jcurry is built on Google Guava and Project Lombok

... jcurry is is a sister project of http://code.google.com/p/javasizzle/'>jsizzle

Project Information

Labels:
java functional currying collections