Discrete math algorithm - Combinations of combinations of arrays

I've spent more than 3 days now trying to write an algorithm to do this, but can't find a way... That D is discrete structure in college is coming back to haunt me now I guess...

Trying to find an algorithm to generate all combinations, of all combinations, of n arrays. I found a decent class on the net (google: java array combinations) that generates combinations of a single array taken n at a time, and it was simple enought to adapt it to give all combinations from length 1-array.length.

See example below for possible output;

String[] t = {"X","Y","Z"};

String[] r = {"A","B","C"};

String[] j = {"P","Q","R"};

// generate all combinations of all combinations of all arrays

// ex (line breaks for clarity only)

// X, Y, Z, XY, XZ, YZ, XYZ

// A, B, C, AB, AC, BC, ABC

// P, Q, R, PQ, PR, QR, PQR

// XA, XB, XC, XAB, XAC, XBC, XABC

// XP, XQ, XR, XPQ, XQR, XPQR

// YA, YB, YC, YAB, YAC, YBC, YABC

// YP, YQ, YR, YPQ, YQR, YPQR

// ...

// XAP, XAQ, XAR, XAPQ, XAPR, XAQR, XAPRQ

// ...

// XYZABCP, XYZABCQ, XYZABCR, XYZABCPQ, XYZABCPR, XYZABCQR, XYZABCPQR

// done

[1188 byte] By [pcowan67a] at [2007-11-27 9:39:52]
# 1
A hint: at least when there are no identical elements, it looks like all combinations of the union.
BIJ001a at 2007-7-12 23:16:06 > top of Java-index,Java Essentials,Java Programming...
# 2
You can just add all elements from t, r and j in one set and then generate the power set of it: no need to keep it in multiple arrays. http://mathworld.wolfram.com/PowerSet.html
prometheuzza at 2007-7-12 23:16:07 > top of Java-index,Java Essentials,Java Programming...
# 3

Right you are, thanks! The solution was too simple for me to see.

> You can just add all elements from t, r

> and j in one set and then generate the power

> set of it: no need to keep it in multiple arrays.

>

> http://mathworld.wolfram.com/PowerSet.html

pcowan67a at 2007-7-12 23:16:07 > top of Java-index,Java Essentials,Java Programming...
# 4
> Right you are, thanks! The solution was too simple> for me to see.You're welcome.
prometheuzza at 2007-7-12 23:16:07 > top of Java-index,Java Essentials,Java Programming...