module Enumerable def cartesian(other) inject([]) { |res, x| other.inject(res) { |res, y| res << [x,y] } } endend