From: Christian Neukirchen Date: 2008-09-23T02:44:35+09:00 Subject: Re: [QUIZ] One-Liners Mashup (#177 again) class Array # the classic def repeat(n) r = []; each { |e| n.times { r << e } }; r end # the nice def repeat(n) inject([]) { |a,e| a.concat [e]*n } end # the probably most efficient def repeat(n) Array.new(size*n) { |i| self[i/n] } end end # next challenge: return the power set of an Array's elements # (my solution: https://gist.github.com/e05c3be86abf74b44853)