Created
April 24, 2014 01:43
-
-
Save ariela/11238689 to your computer and use it in GitHub Desktop.
Java8でカリー化の実験
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 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