# How to use Table function with two parameters executed when they are not equal? [duplicate]

I have a list,

param2 = {
{-qlim, -qlim},
{-qlim, qlim},
{qlim, -qlim},
{qlim, qlim}
};


and want to get combination of them with,

Flatten[Table[{param2[[i]], param2[[j]]}, {i, 4}, {j, 4}], 2]


But this gives me list which includes sets that have item twice. I want to get

{1,2},{1,3},{1,4},{2,3},{2,4},{3,4}

• What's the value of qlim? Jan 1, 2017 at 22:53
• it is a scalar value like 1 or 3 Jan 1, 2017 at 22:54
• That's not the answer to my question. I still don't know what do you want to achieve with your code, but the desired output can be obtained with Flatten[Table[{i, j}, {i, 1, 4}, {j, i + 1, 4}], 1]. Jan 1, 2017 at 22:55
• Actually ı have written the index inside the list not the actual output. I didn't know that we can use one index inside other. I will try it tomorrow. Thank you. Jan 1, 2017 at 23:07
• Jan 1, 2017 at 23:16

Subsets[param2, {2}]


{{{-qlim, -qlim}, {-qlim, qlim}},
{{-qlim, -qlim}, {qlim, -qlim}},
{{-qlim, -qlim}, {qlim, qlim}},
{{-qlim, qlim}, {qlim, -qlim}},
{{-qlim, qlim}, {qlim, qlim}},
{{qlim, -qlim}, {qlim, qlim}}}

• Thanks that's what I wanted. What if ı just wanted this point to draw rectangle with these points are corner. Jan 1, 2017 at 23:12
• @freezer, something like Graphics[{Hue@RandomReal[], Rectangle @@ #}] & /@ (Subsets[ param2, {2}] /. qlim -> 1)?
– kglr
Jan 1, 2017 at 23:23
• nope @kglr. I think this is not what I asked. I want to get this list {{{-3, -3}, {3, -3}}, {{3, -3}, {3, 3}}, {{3, 3}, {-3, 3}}, {{-3, 3}, {-3, -3}}} as corners of ractangles automatically? Is this possible? Jan 2, 2017 at 23:28
• @freezer, Rectangle @@@ {{{-3, -3}, {3, -3}}, {{3, -3}, {3, 3}}, {{3, 3}, {-3, 3}}, {{-3, 3}, {-3, -3}}} gives {Rectangle[{-3, -3}, {3, -3}], Rectangle[{3, -3}, {3, 3}], Rectangle[{3, 3}, {-3, 3}], Rectangle[{-3, 3}, {-3, -3}]}. Note that some of these are simply lines (degenerate rectangles).
– kglr
Jan 2, 2017 at 23:40
• :) I think I couldn't be clear as I need. I need to get that list from possible values of coordinates. Don't want to write manually. Jan 3, 2017 at 0:02