4 ms·
You might enjoy this paper, which presents "stream fusion", a technique which can do what you're talking about as well as a bunch of other cool stuff: http://ci
by tonyg 4y ago
You might enjoy this paper, which presents "stream fusion", a technique which can do what you're talking about as well as a bunch of other cool stuff: http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.104.7401 http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.104.7...
"Stream Fusion: From Lists to Streams to Nothing at All." Duncan Coutts, Roman Leshchinskiy, Don Stewart. ICFP 2007.
- cryptonector 4y agoYes. I knew this as list fusion. Note that Rust doesn't need to do this because of the way `iter_into()` and mapping works. List fusion boils down to removing interior `.collect().iter_into()`. There is something to be said for designing APIs so that you don't need such rewrite rules, though, of course, the need comes up eventually anyways, so rewrite rules end up being kinda necessary.