Array#map
, Array#filter
create a new array and hence effectively iterating over the array (or creating new array).
Whereas in rust, python, java, c#, etc. such expression chain will iterate only once.
In most cases this is irrelevant and we do not have to care about that. However in some cases the performance hit could be a deal breaker to leverage the function api of the Array
class.
How do you mitigate this? So you have any preference on a library enabling lazy evaluation for functional expression?
reduce
is chained further with amap
? How can that in general work without first performing the whole iteration needed to perform the reduction?npm i stream-list