Fork me on GitHub

Any thoughts on refactorings for cycling through different ways to perform iteration? Something like: • doseq <-> run!`mapv` <-> into • on the riskier side, collection transformations e.g. ->> <-> transduce • etc.


Why would you change mapv into into? mapv already calls into


@U04V15CAJ Ah, I didn't know that! Do you think there are any valid cases for a code action like this?


I like the doseq -> run! one, since run! yields smaller code


The ->> -> transduce one seems like a nice efficiency upgrade. The stack is essentially the same in both, but the transducer doesn't retain everything in memory.


->> with seqs also doesn't retain everything in memory?


if you release the head of a seq, it can be garbage collected


but yeah, if this can be done accurately, it would be nice


My understanding is that it still creates intermediate sequences between each step and puts a strain on the GC when using a large collection, while the transduce version does not. In any case, the example list is short and not complete. There are probably a few other such transforms that could be considered.


This is true, but it doesn't hold everything in memory


I see. So still an efficiency gain but not for all the reasons I thought. Thanks for the correction.


FWIW Alex Miller tool developers to support a ->> <-> eduction refactoring 7 years ago. eduction is still pretty obscure, from what I’ve seen, but perhaps it should be another candidate


Thanks, @U07M2C8TT. Okay, it sounds like there is at least a little interest in this idea. I'll create an issue for it just to put it on the radar.