Skip to content

Instantly share code, notes, and snippets.

@eyelash
Created September 28, 2019 19:02
Show Gist options
  • Save eyelash/7be71cf42b902c08d76d557a95f0d89b to your computer and use it in GitHub Desktop.
Save eyelash/7be71cf42b902c08d76d557a95f0d89b to your computer and use it in GitHub Desktop.
/**
* 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