0
Difference between map and takewhile?
So basically takewhile is the same as map but takes a predicate function (bool returning function) instead of a generic function. Am I saying right?
3 Answers
+ 7
map applies a function to every element of an iterable (for example a list). takewhile returns elements from an iterable and stops as soon as one element doesn't meet the condition.
Here's an example:
https://code.sololearn.com/c6ZYNt708vTS/?ref=app
+ 6
So if you want to compare, compare with filter:
filter filters up to the end, takewhile terminates at first miss.
+ 2
Helo