Exercises Bookstore more
Use Case 1: Partition Books by Availability of Description
library.partition(_.description.isDefined)
Use Case 2: Find the Most Expensive Book
library.sortBy(-_.price).headOption
Use Case 3: Get Distinct Authors
library.map(_.author).distinct
Use Case 4: Flatten Nested List of Book Lists
bookLists.flatten
Use Case 5: Extract Titles of Books by a Specific Author Using flatMap
library.flatMap(book => if (book.author.name == authorName) Some(book.title) else None)
Use Case 6: Calculate Total Price of Books Using foldLeft
library.foldLeft(0.0)((total, book) => total + book.price)
Use Case 7: Combine Books and Authors into a Map
library.groupBy(_.author)