tc39-transfer / proposal-random-functions

Proposal to add a Random namespace and several additional convenience functions for using randomness.
https://tc39-transfer.github.io/proposal-random-functions/
MIT License
3 stars 1 forks source link

sampling arbitrary iterables #4

Open bakkot opened 5 months ago

bakkot commented 5 months ago

This has Random.pickFromList, which is a good and useful function when your list is of known length (though a bad name). But when it's not, you can still usefully sample from it (although it's O(n) to do so). Should we expose that functionality?

tabatkins commented 5 months ago

Yeah, some ability to reservoir sample would be interesting (and very non-trivial to do by hand!)