Last active
September 21, 2017 04:55
-
-
Save Atternatt/e30e0e68cbade9985f39b1df859e8687 to your computer and use it in GitHub Desktop.
monads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sum4 : (Int) -> Int = { value -> value + 4 } | |
var div2 : (Int) -> Int = { value -> value / 2 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum4(4) //return 8 | |
div2(4) //return 2 | |
listOf(3,4,6,8,10) | |
.map(sum4) | |
.map(div2) | |
//[3, 4, 5, 6, 7] | |
fun hello(name: String, textDecorator: () -> String): String { | |
return "hello $name ${textDecorator()}" | |
} | |
hello("marc") { | |
"you are awesome!" | |
} | |
// es lo mismo que | |
hello("marc", {"you are awesome"}) | |
//hello marc You are awesome! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment