Skip to content
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

Associate andThen and compose so that users can find opposite function #14

Closed
wants to merge 2 commits into from

Conversation

exoego
Copy link
Contributor

@exoego exoego commented Jul 5, 2019

These changes will be superseded by #4, but it is good to have as of today.

@exoego exoego mentioned this pull request Jul 5, 2019
@superruzafa
Copy link
Owner

andThen and compose are not "opposed" to each other. They are two ways to express the same calculation but by swapping the two operands.

val f = (x: Int) => x * 10
val g = (x: Int) => x + 10

(f andThen g)(5) // 60
(g compose f)(5) // 60

(g andThen f)(5) // 150
(f compose g)(5) // 150

Also, I prefer the readers to find related functions after have reading the whole article.

@exoego
Copy link
Contributor Author

exoego commented Jul 6, 2019

Could you suggest a sentence to describe compose?

@superruzafa
Copy link
Owner

Both andThen and compose are used to combine other input functions. They do the same job but each one swaps the order the other function applies the input functions.

@exoego exoego force-pushed the andThen-compose branch from 9ce9983 to c1a21e0 Compare July 6, 2019 22:21
@exoego
Copy link
Contributor Author

exoego commented Jul 6, 2019

Both andThen and compose are used to combine other input functions. They do the same job but each one swaps the order the other function applies the input functions.

Thans, updated so.

Spanish paragraphs translated by Google, so could be funny...
If the added sentences looks good, I will add the corresponding Japanese translation soon.

@exoego exoego force-pushed the andThen-compose branch from c1a21e0 to 549fab9 Compare July 17, 2019 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants