[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: scrambler one-liner

Weirich, James

9/17/2003 5:57:00 PM

> Here's a one-liner after all:
>
> gsub!(/\B\w+\B/){proc{|s|Array.new(s.length){s.delete_at(rand(
> s.length))}}.call($&.split(//)).join}
>
> It's longer for sure, but now you're sure the result is really random
> (provided you believe me it is ;-)

Just for clarification, my concerns rested with sort{rand}. The original
one-liners using sort_by{rand} should be fine with regards to randomness.

--
-- Jim Weirich / Compuware
-- FWP Capture Services
-- Phone: 859-386-8855