# Create the Cartesian product of two sets

David shared this question 3 years ago

I am trying to create the Cartesian product of two sets l1 and l2.

I attempted Zip(zip({a,b},a,l1),b,l2) but that did not work in graphing app, classic app or CAS app.

I also tried to use the spreadsheet but it does not like ={x,y} or =(x,y) in A1. Not to mention I don't know how to paste a set vertically in a spreadsheet.

Anyone know how to find the Cartesian product?

Thanks. 1

How's that?

```Sequence(Sequence((Element(l1, i), Element(l2, j)), i, 1, Length(l1)), j, 1, Length(l2))
```
If not, please say exactly what you want as output 1

zip(zip({P,Q},P,l1),Q,l2)

flatten optional 1

Yes. The first answered my question. I will take a look at the other answers to see which is the easiest to use. Thank you. 1

I would like to construct a 2-parameter sequence c_{nm} by taking the cartesian product of two sequences {a_n} and {b_m}. The command SEQUENCE allows only one variable. Looking forward to hearing about the solution.  1

el procedimiento ya ha sido explicado arriba