ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: scramble sentence, how to better program?
by David A. Black other posts by this author
May 8 2008 2:51PM messages near this date
Re: scramble sentence, how to better program? | Re: scramble sentence, how to better program?
Hi --

On Fri, 9 May 2008, S2 wrote:

>  David A. Black wrote:
> 
> > print "Enter a sentence: "
> > puts gets.split.sort_by { rand }.join(" ")
> 
>  but does this take into account that rand could generate the same numer two
>  times? while that is not likely, it could happen.

I'm by no means a random number expert/theorist, but the above is a
very common idiom. I don't really know how it holds up under full
scrutiny. There's probably some discussion of that in the archives.


David

-- 
Rails training from David A. Black and Ruby Power and Light:
   INTRO TO RAILS         June 9-12            Berlin
   ADVANCING WITH RAILS   June 16-19           Berlin
   INTRO TO RAILS         June 24-27           London (Skills Matter)
See http://www.rubypal.com for details and updates!
Thread:
Globalrev
David A. Black
S2
S2
Globalrev
S2
7stud --
David A. Black
Rob Biedenharn
S2
S2

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved