Dan Zwell wrote:
> Lloyd Linklater wrote:
>> dang it!  I *knew* that I should have been thinking more ruby and less 
>> pascal.  This may look more rubyish:
>> 
>> def arr_rand(ar)
>>   arr = []
>>   while ar.length > 0 {arr << ar.delete_at(rand(ar.length))}
>>   arr
>> end
> 
> Yes, that is fairly simple to understand. But it is equivalent to
> sort_by {rand} in that it does not actually change the array that is
> passed in. 

Actually, it was different.  The sort_by {rand} gives the same sequence 
of shuffling every time you run it.  Mine is different every time.  I 
get a bang out of the declaration you have.  That is a nice touch.  I 
also like your use of until temp.empty?  That is very Ruby-ish to me. 
:)
-- 
Posted via http://www.ruby-forum.com/.