From: Timo Hoepfner Date: 2005-12-07T21:54:34+09:00 Subject: Build array of possible combinations Hi, I'm looking for an easy way to convert a string representing a boolean expression like "(a and (b or c) or d" to an Array of Arrays (representing sets) representing all possible valid combinations like: [["a","b"],["a","c"],["d"]] Background: I want to build a tree structure, where constraints like the one above are attached to the nodes. They describe, which combinations of children are allowed and what valid combinations are left once one or more children are already selected. I'm already doing something like that in Java, but supply the list of possible combinations by hand, which quickly gets annoying... The rest is done via set operations. The actual business logic is similar to (pseude code which looks like Ruby from a Ruby-Newbie's POV...): set=MySet.new [["a","b"],["a","c"],["d"]] set.remaining_choices_for [] --> ["a","b","c","d"] set.remaining_choices_for ["a"] --> ["b","c"] set.remaining_choices_for ["d"] --> [] set.complete_for? ["a"] --> false set.complete_for? ["a","b"] --> true set.complete_for? ["d"] --> true If you can think of a better approach, please tell... Thanks for your help, Timo