NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
also a favourite (Score:1)
perl -le 'print chr(65+rand(26))'
your version is prettier, though
(sorry, i'm not a java person)
bgp is for those who can't keep it static long enough
Re: (Score:2)
Damn. I thought my version is crystal clear, but yours is just perfect and obvious -- if you know ASCII.
And doing that in Java:
Re: (Score:1)
If this is for a party game, isn't the exception handling gratuitous? Whether it fails with a stack track or a nice error message, it's screwed up. Can't you just omit that?
Why do you need the reader at all? Is there some requirement that you must read from stdin if you want to send to stdout?
rjbs
Re:also a favourite (Score:2)
The reason for the reader is that the game were were playing required we think of words for categories but each word had to start with a particular letter. The reader was there to ensure we could just hit "Enter" and get the next letter. So if we just rerun java Pick every time, we can get it to this:
This doesn't replicate the exact functionality of the Perl, though, which is really what the post was about. If I want the 'hit enter for a new letter' functionality, the minimum I can write seems to be this:
I've stubbed out the exception (a notorious but common practice) because that's a checked exception and failure to catch it is a compile time error. Checked exceptions are so common that you wind up with fun boilerplate like this [google.com]:
Reply to This
Parent