val titles = library.map(_.title)
val prices = library.map(_.price)
titles.zip(prices)
library.map(_.title).zipWithIndex
val authors = library.map(_.author.name).distinct
val booksByAuthor = authors.map { author =>
val books = library.filter(_.author.name == author).map(_.title)
(author, books)
}
booksByAuthor
val titles = library.map(_.title)
val years = library.map(_.year)
titles.zip(years)
val originalPrices = library.map(_.price)
val discountedPrices = originalPrices.map(price => price * (1 - discountRate))
originalPrices.zip(discountedPrices)
library.map(_.title).zipWithIndex.map { case (title, index) => s"$index: $title" }