I am trying out Scala exercise where for expression is converted to higher order function - flatMap, filter and map. I don't understand how the input to map(List(author1,author2)) is translated to book.title.
Input:
val books:List[Book] = List(
Book(title = "kids watching", authors = List("Aavik","Arjun"))
)
For expression:
for{
book <- books
name <- book.authors
if name.startsWith("Aavik")
} yield book.title
Higher order function:
books flatMap(book =>
book.authors filter(name => name startsWith("Aavik")) map(_ => book.title))
Input to map is List("Aavik") and how does the map relates to book.title?