Question: what is the difference between map and flatmap?
Answer: The difference is that the map operation produces one output value for each input value, whereas the flatMap operation produces an arbitrary number (zero or more) values for each input value. ... The flatMap operation takes a function that conceptually wants to consume one value and produce an arbitrary number of values.