Syndicate: [full] [short]
1 of 1 article
Ruby Haiku 137
25 Jan 05    [print link all ]

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