Live data from Hacker News

Javascript Arrays and Functional Programming

zabanaa.github.io

91–92 of 92 posts

Re: Javascript Arrays and Functional Programming

#91

Earlier quoted context omitted.

Man, I had just worked up the nerve to start a personal dev blog but you've just scared me straight off.

I have wanted to start a personal dev blog myself for quite a while, but each time I think of a suitable topic, I immediately recall an article or a post that is already better than anything I could write myself on the matter. If you think you have something valuable or interesting or just funny to share, that either was never discussed or written about or you know you can do better, then you absolutely should blog a…

> I have wanted to start a personal dev blog myself for quite a while, but each time I think of a suitable topic, I immediately recall an article or a post that is already better than anything I could write myself on the matter.

Sounds like you should be curating a list.

Re: Javascript Arrays and Functional Programming

#92
post #89

Earlier quoted context omitted.

The problem with this is that it generates two intermediate arrays in the maps, then effectively drops them in the reduce. This may be inefficient. I wish that JavaScript's map/filter/reduce functions returned lazy iterators, like in Rust, so that code like this doesn't produce intermediate arrays. Does anyone know of a library that provides this?

Those intermediate iterations could be dropped by composing the map functions together (same with the reduce), if that really was a performance bottleneck.

With lazy iterators, there is the possibility of better composition of maps/filters/reduces. That's why I'm a fan of the lazy iterators approach -- otherwise the abstraction breaks too easily and it ends up looking like a for-loop anyway.
Post reply on HN