class Array def power inject([[]]){|ps, e| ps + ps.map{|s| s + [e]}} end end p [1,2,3].power [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]
Quote saved.
Login to quote this blog
Failed to save quote. Please try again later.
You cannot quote because this article is private.