[CrackMonkey] Beaujolais to Lisp!
1paul at optushome.com.au
Wed Jul 18 03:22:22 PDT 2001
On Tue, Jul 17, 2001 at 10:25:18PM -0700, Mr. Bad wrote:
> >>>>> "PC" == Paul Cameron <1paul at optushome.com.au> writes:
> Me> It's actually a pretty fun proof.
> PC> Yes. perlfaq5.
> PC> Blah a vous.
> Well, wait a sec:
> How do I select a random line from a file?
> Here's an algorithm from the Camel Book:
> rand($.) < 1 && ($line = $_) while <>;
> This has a significant advantage in space over reading the
> whole file in. A simple proof by induction is available
> upon request if you doubt the algorithm's correctness.
> It actually doesn't have the proof in it.
No, you have to ask Tom Christiansen for it.
More information about the Crackmonkey