Skip to content

Currying #1842

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

Closed
javatlacati opened this issue Oct 7, 2021 · 7 comments · Fixed by hkattt/java-design-patterns-currying#1 or #2271
Closed

Currying #1842

javatlacati opened this issue Oct 7, 2021 · 7 comments · Fixed by hkattt/java-design-patterns-currying#1 or #2271

Comments

@javatlacati
Copy link

I's a functional programming design pattern. As far as I understand you call a function with less parameters than usual and it can be used to defer processing when it has many steps involved.

UML example

@startuml
'https://plantuml.com/class-diagram

interface BiFunction <ParamType1, ParamType2, ResultType>{
}

interface Curried<ParamType1, ParamType2 extends Simple> {
  +ParamType2 apply(final ParamType1 a);
}

interface Simple<ParamType1, ParamType2, ResultType> extends BiFunction {
  +ResultType apply(final ParamType1 a, final ParamType2 b);
}

@enduml

image

With the curried version you can do stuff like:

   System.out.println(curriedAdd.apply(4).apply(5));

    Function1<Integer, Integer> adder5 = curriedAdd.apply(5);
    //some complicate and time consuming process here
    System.out.println(adder5.apply(4));
    System.out.println(adder5.apply(6));

@iluwatar
Copy link
Owner

iluwatar commented Oct 8, 2021

There is a concrete example about currying in Java on Baeldung's website: https://www.baeldung.com/java-currying

@januslinhc
Copy link

januslinhc commented Oct 11, 2021

hi @iluwatar , can I work on this issue for Hacktoberfest?

@iluwatar
Copy link
Owner

Sure @januslinhc, it's now assigned to you

@hkattt
Copy link
Contributor

hkattt commented Oct 10, 2022

Hey @iluwatar, could I work on this issue?

@iluwatar
Copy link
Owner

All right @hkattt, you're free to proceed

hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 17, 2022
hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 18, 2022
hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 18, 2022
hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 18, 2022
hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 18, 2022
hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 18, 2022
hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 18, 2022
hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 18, 2022
hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 19, 2022
hkattt pushed a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 20, 2022
@iluwatar iluwatar moved this to In Progress in Java Design Patterns project Oct 29, 2022
hkattt added a commit to hkattt/java-design-patterns-currying that referenced this issue Oct 29, 2022
@stale
Copy link

stale bot commented Nov 28, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale issues and pull requests that have not had recent interaction label Nov 28, 2022
@iluwatar
Copy link
Owner

iluwatar commented Dec 3, 2022

@hkattt is still working on this

@iluwatar iluwatar removed status: stale issues and pull requests that have not had recent interaction priority: normal labels Dec 3, 2022
Repository owner moved this from In Progress to Done in Java Design Patterns project Dec 4, 2022
iluwatar pushed a commit that referenced this issue Dec 4, 2022
* #1842 Setting up project and creating example classes. Issues running site and deploy

* #1842 Added unit tests

* #1842 Improved example

* #1842 Added UML class diagram

* #1842 Added comments to Genre class

* #1842 Improved readability of lambda function

* #1842 Started working on the README and created initial UML

* #1842 Added example to README

* #1842 Replaced prints with LOGGER

* #1842 Fixed typo in README

* #1842 Testing commit account

* #1842 Adding documentation to App class

* #1842 Improved documentation

* #1842 Added documentation to AppTest

* #1842 Fixing latex formating issue

* #1842 Improving the intent description

* #1842 Removed override methods from the UML diagram for clarity

* #1842 Renamed the SCI_FI enum

* #1842 Updated the currying pom.xml

* #1842 Removed unneeded comment

* #1842 Improving documentation and README

* Added review changes.

* Fixing build issues and added javadoc comments to functional interfaces.

* Removing code smells

* Removed unnecessary toString method

* Using lombok to reduce boiler plate.

* Fixed frontmatter.

* Removing function name code smell

* Fixed README typo

* Added book_creator test to improve coverage

Co-authored-by: Hugo Kat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment