Created
September 28, 2019 19:02
-
-
Save eyelash/7be71cf42b902c08d76d557a95f0d89b to your computer and use it in GitHub Desktop.
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
/** | |
* You can edit, run, and share this code. | |
* play.kotlinlang.org | |
*/ | |
fun List<String>.iterate(f: (String) -> String) = map(f).joinToString(separator = "") | |
fun main() { | |
val fruits = listOf("apple", "strawberry", "banana") | |
val html = """ | |
<html> | |
<li> | |
${fruits.iterate {fruit -> """ | |
<ul>$fruit</ul> | |
"""}} | |
</li> | |
</html> | |
""" | |
println(html) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment