flatMap

val books = listOf<Book>(
    Book("book1", listOf("a", "b")),
    Book("book2", listOf("c", "d")),
    Book("book3", listOf("e", "a"))
)
val authors = books.flatMap { it.authors }.toSet()
// val authors = books.map { it.authors }.fatten().toSet()
println(authors)
// [a,b,c,d,e]
data class Book(
    val title: String,
    val authors: List<String>
)