From: Erik Terpstra Date: 2004-05-13T17:38:51+09:00 Subject: How to make combinations of an array to produce all possible expressions? I have an array 'conds', which contains some sub-expressions for an xpath query: conds = ["@title='Foo'", "@edition='Bar'", "@date='20040513'"] Is there an existing library that lets me construct all possible combinations like this? puts conds..collect{|n| n.join ' and '} which produces: @title='Foo' and @edition='Bar' and @date='20040513' @title='Foo' and @edition='Bar' @title='Foo' and @date='20040513' @edition='Bar' and @date='20040513' @title='Foo' @edition='Bar' @date='20040513'