How do i generate a list of all tuples in element R in haskel

151 Views Asked by At

I just cant find a way to generate tuples in element R like (1,2) Thats should make <1,1>,<1,2><2,1><2,2>

1

There are 1 best solutions below

0
Louis Wasserman On

The shortest and most convenient way to take two lists x and y and generate tuples from them is

liftM2 (,) x y

The most self-explanatory way to do this is

[(a, b) | a <- x, b <- y]