+ 4

What difference between filter and takewhile function?

26th Jul 2016, 5:21 AM
–ź–Ĺ–≤–į—Ä –ė—Ā–ľ–ĺ–ł–Ľ–ĺ–≤
–ź–Ĺ–≤–į—Ä –ė—Ā–ľ–ĺ–ł–Ľ–ĺ–≤ - avatar
2 Respuestas
+ 17
filter will iterate through whole input iterator while takewhile will break once the predicate turn False, if you have an iterator with 1st element that false to predicate, takewhile will break at 1st iteration and return empty
25th Nov 2016, 4:02 PM
skycc - avatar
+ 6
filter: don't need import.Returns all the elements that satisfy the predicate. takeWhile: Returns the longest prefix whose elements satisfy the predicate.
26th Jul 2016, 5:35 PM
César Augusto Gaete
César Augusto Gaete - avatar