Skip to content

Instantly share code, notes, and snippets.

@ariela
Created April 24, 2014 01:43
Show Gist options
  • Save ariela/11238689 to your computer and use it in GitHub Desktop.
Save ariela/11238689 to your computer and use it in GitHub Desktop.
Java8でカリー化の実験
package curry;
import java.util.function.Function;
interface F<T, R> extends Function<T, R> {}
public class Curry {
public static void main(String[] args) {
F<Integer, F<Integer, Integer>> compare = max -> x -> (max <= x) ? max : x;
F<Integer, Integer> f = compare.apply(10);
System.out.println(f.apply(0));
System.out.println(f.apply(5));
System.out.println(f.apply(10));
System.out.println(f.apply(99));
System.out.println(f.apply(9999));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment