-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Java implementation #1
base: master
Are you sure you want to change the base?
Conversation
Added Java implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job :)
Could you please add a few code style and formatting changes?
class Closure { | ||
|
||
public static void main(String[] args) { | ||
Function<Double,Function<Double,Double>> createLog = (Double base) -> (Double n) -> log(base, n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style. And could you split this line to fit 100 symbols in line, please? Just a code style suggestion.
} | ||
|
||
private static Double log(Double base, Double n) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style.
public static void main(String[] args) { | ||
final TriFunction<Integer,Integer,Integer,Integer> add = Curry::sum; | ||
Function<Integer, Function<Integer, Function<Integer,Integer>>> uncurry = Curry.curry(add); | ||
TriFunction<Integer,Integer,Integer,Integer> curry = Curry.uncurry(uncurry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatting.
return a + b + c; | ||
} | ||
|
||
private static <A, B, C, D> Function<A, Function<B, Function<C,D>>> curry(final TriFunction<A, B, C, D> f) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you split this line to fit 100 symbols in line, please? Just a code style suggestion.
return (A a) -> (B b) -> (C c) -> f.apply(a, b, c); | ||
} | ||
|
||
private static <A, B, C, D> TriFunction<A,B,C,D> uncurry(Function<A, Function<B, Function<C, D>>> f) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you split this line to fit 100 symbols in line, please? Just a code style suggestion.
} | ||
|
||
@FunctionalInterface | ||
public interface TriFunction<A,B,C,D>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatting.
# IntelliJ | ||
/out/ | ||
/.idea | ||
*.iml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add extra line break at EOL
Added Java implementation by Serhii Frolov IT-42