February 2018
Intermediate to advanced
350 pages
7h 35m
English
Reverse takes any function and returns it with its parameter in the reverse order (in other languages, this function is known as flip). Let's look at the following code:
import arrow.syntax.function.partially3import arrow.syntax.function.reversefun main(args: Array<String>) { val strong: (String, String, String) -> String = { body, id, style -> "<strong id=\"$id\" style=\"$style\">$body</strong>" } val redStrong: (String, String) -> String = strong.partially3("font: red") //Explicit println(redStrong("Red Sonja", "movie1")) println(redStrong.reverse()("movie2", "The Hunt for Red October"))}
Our redStrong function is awkward to use, as we'll expect to have id first and then body, but, is easily fixable with the reverse extension function. ...
Read now
Unlock full access