This post originated from an RSS feed registered with Ruby Buzz
by Rudi Cilibrasi.
Original Post: Ruby Haiku 137
Feed Title: Esoteric Ruby Blog
Feed URL: http://cilibrar.com/~cilibrar/erblog.cgi/index.rss
Feed Description: A weblog made to explore some Ruby ideas in great detail and try to work out ideal solutions to real problems.
class Array
def scramble() dup.scramble! end # scramble v. 0.15
def swap(i,j) self[i],self[j] = at(j),at(i) end # by cilibrar
def scramble!() each_index() { |i| swap(i,i+rand(size-i)) } end
end