
Hi,
Look up "reservoir sampling", it will most probably help.
On Sun, Jun 10, 2012 at 6:21 AM, Noon Silk
Hi,
I'm clearly new to haskell, and I suppose those is a basic question, but after a bit of searching I've been unable to figure out the "best" way to do this. I was first trying to find out how to, say, get a random element from a list, but I'm starting to think that may not be the best way (because list access isn't constant time, among other reasons). So, I wonder if there is a more direct way to just get a random word from a wordfile (i.e. one word per line) ... can anyone suggest a method?
Ideally I'd like to be able to adapt this to get n random words from several files (i.e. randomly select n words from all files; i.e. just read them into one merged array and choose from there?)
Thanks for any advice ...
-- Noon Silk
Fancy a quantum lunch? https://sites.google.com/site/quantumlunch/
"Every morning when I wake up, I experience an exquisite joy — the joy of being this signature."
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Eugene Kirpichov Principal Engineer, Mirantis Inc. http://www.mirantis.com/ Editor, http://fprog.ru/