What's a good, non-recursive algorithm to calculate a Cartesian product?
问题 Note This is not a REBOL-specific question. You can answer it in any language. Background The REBOL language supports the creation of domain-specific languages known as "dialects" in REBOL parlance . I've created such a dialect for list comprehensions, which aren't natively supported in REBOL. A good cartesian product algorithm is needed for list comprehensions. The Problem I've used meta-programming to solve this, by dynamically creating and then executing a sequence of nested foreach