Closed exoego closed 2 years ago
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.
Could you suggest a sentence to describe compose?
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.
Both
andThen
andcompose
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.
These changes will be superseded by #4, but it is good to have as of today.