2 ms·
In a lot of languages, stdlibs, what have you, map is implemented in terms of a reduce like this. In a non-lazy language, this kind of a reduce is usually nece
by 15155 11y ago
In a lot of languages, stdlibs, what have you, map is implemented in terms of a reduce like this.
In a non-lazy language, this kind of a reduce is usually necessary when you want to omit an item efficiently from the resultant array - map does not offer a way to do this.
- sedachv 11y agoDid you miss the explicit side-effects in the code above? This isn't like a map/filter in terms of fold, it is a very stupid way of writing a 'for' loop.