From: Harpo Date: 2005-12-08T05:42:35+09:00 Subject: Re: Build array of possible combinations Timo Hoepfner wrote: > Hi, > > I'm looking for an easy way to convert a string representing a > boolean expression like > > "(a and (b or c) or d" Unpaired parentheses ! (I was a compiler in a previous life, I just can't help ;)) > > to an Array of Arrays (representing sets) representing all possible > valid combinations like: > > [["a","b"],["a","c"],["d"]] The question is interesting, my answer is probably a bad hack. Say you use a regular expression to transform the string in "exp([a.xand([b,c]),d]) Maybe it is possible. I think it is. It seems to be a well formed Ruby expression and can be parsed by Ruby using eval, you just have to write the xand mathod ('and' is likely to be a reserved word in a language) end the exp method, maybe the same as xand. This methods can build the array you need. Well, It is just a direction. I thank you for this problem. -- email : jigmepema wanadoo fr